Source File Layout
package definition - groups classes together that need access to shared members
variables or methods. 
import statement(s) - to use a class in another package, import the class via the
classes package. 
public class MyClass [extends Superclass] [implements Interface(s)] 
 
{ 
  class variables - static variables. Exists only once. (belong to class) 
  instance variables - non-static variables belong to an instance of a class. (belong
  to object) 
  static initializers - use keyword: static { } (belong to class). Runs as class
  loads. 
   
  constructors ( [arguments] ) { } - constructor method(s) by the same name as the
  class name. Automatically run at instantiation. If more than one by the same name, then
  the signature (arguments) must be unique. There is no declared return type! 
   
  class Methods - static methods exist at load time. (belongs to the class).
  If more than one by the same name, then the signature (arguments) must be unique. Must
  declare a return type. 
   
  instance Methods - non-static methods that exist at instantiation. (belong to
  object). If more than one by the same name, then the signature (arguments) must be
  unique. Must declare a return type. 
 
} 
 
Other classes that are not public. (only one public class is allowed per .java
file.) 
 
interface MyInterFace //Is abstract even if you do not define as so. 
{  
  public int intSerialNum = 987654; //Is static & final even if you do not
  define as so. 
  public String getVersion(); //All methods are abstract even if you do not define as
  so.  
  public String getProgrammer(); //Notice, no code! No code blocks {}.  
 
} 
  |