University of Cincinnati logo and link  
Creating a Class
 
  UC ingot 
  • Building a program normally requires a number of classes.
    • One must have the public static void main(String args[]) method, often simply called a main method.  This is the one that starts the entire program.
    • Others need not have a main method, but often do for unit testing purposes.
  • Nearly all classes have instance fields and methods.  I'd have a hard time thinking of a class that wouldn't.
  • All classes require constructors.
    • If you do not have a constructor or cannot afford one, Java will provide one for you.
    • This is called the default constructor, it takes no arguments (parameters).
    • You can have parameters in a constructor if you specify them.  If you do this, or if you simply make one without parameters, Java will not create the default constructor.