First Class — Not Typical
Minimal Class for a Minimal Program
- Consists of 1 class, 1 method, and 1 statement.
/**
* Simple program example:
* This is the simplest type of class that produces output.
* It has 1 class, with a single method that has a single statement.
*
* @author Ann Instructor, 1 January 2016
*/
public class VerySimpleProgramClass
{
/** The main function initiates execution of this program. */
public static void main()
{
System.out.println ("Hello, world!");
}
}
- Not a typical class: provides a structure for its single method,
but it does not define a new type — does not encapsulate
data and a set of operations that act on that data.
-
We can use it, though, as a starting point for a program whose other
classes DO define new data types. The
main
method is an
example of pure client code.
Alyce Brady, Kalamazoo College