CSC 8310 -- Very simple Java program

David Matuszek,   dave@acm.org
Fall 1998, Villanova University

This is about as simple as a Java program can be and still make some use of classes.

class Person
{
  String name;
  int age = 20;
  
  void birthday ()
  {
    age++;
    System.out.println (name + " is now "+  age);
  }
}

public class People
{
  public static void main (String args [])
  {
    Person john;
    john = new Person ();

    Person mary = new Person ();

    john.name = "John Doe";
    john.birthday ();
  }
}

To compile:

javac People.java
Compiling produces these two bytecode files:
People.class
Person.class

To run:

java People

Results:

John Doe is now 21