A very simple example which we'll use in class to discuss variables, object creation and sending messages
C. Jones, May 2000

    C. Jones - CMPUT 114 Example Java program - discussed in class, prep for lab exercise 2 
   Very simple example of variables, creating objects, sending messages
import java.util.*; // we need this so we can access code from the Date class

public class Simple {
     public static void main(String args[]) {

        // useful for Ex 2a
        System.out.println( "Hello World!" ); 
        System.out.println("Hello World!".toUpperCase());

        // useful for Ex 2c
        Date aDate;                 // declare a local variable called aDate, of type Date.
        aDate = new Date();         // aDate now stores a reference to a newly created Date object.
        System.out.println(aDate);  // display object referred to by variable aDate. 
                                    // (ie. prints date)  Can print a Stack object similarly
        Stack myStack;              // declare a new variable called myStack of type Stack
        myStack = new Stack();      // myStack now stores reference to newly created Stack object

        // not needed in Ex 2c, but good for understanding Stack
        myStack.pop();              // myStack is empty again!