Program Construction

Class

Constructor

Methods

  • Methods Overview
  • Accessors & Mutators

Syntax

  • Comments
  • Naming Conventions
  • Constants
  • Variables
  • Shorthand
  • Increment & Decrement
  • Escape Sequences
  • And / Or
  • Exit
  • ASCII

Rules

  • Compatibility
  • Precedence and Associativity

 

Construction of a Program

// Sample Program

public class FirstProgram //Name of class (program)
{
  public static void main(String[] args) //The main method
   {
    System.out.println("This is an example output.");
    System.out.println("Below is a sample calculation.");
    int answer;
    answer = 2 + 2;
    System.out.println("2 plus 2 is " + answer);
   }
}
/*
System.out // is an object
println // method invoked by object System.out
("Argument") // the information within the parentheses is data to be output