// JAVA TEST CODES AKA MY FIRST JAVA PROGRAM // Save this file as Citizen.java in your java test codes folder // I'll explain what I'm doing as we go along // First, I create a new class called Citizen public class Citizen // Enclose the class with an opening bracket { // Here, I define two attributes of class Citizen both with String datatype String name; String country; // Then I specify a constructor for Citizen class and initialize my variables public Citizen () { name = "Aureo P. Castro"; country = "Philippines"; } // Here, I define one method that display the details of a Citizen object public void displayCitizenDetails () { // This method will print first a blank line then three lines of details System.out.println (); System.out.println ( "Class Citizen"); System.out.println ( "Name of Citizen = " + name ); System.out.println ( "Country of Citizen = " + country ); } // Now, here is my main method public static void main ( String args [] ) { // First, it creates a new instance of Citizen class called citizenOying // Then, it calls the display method we created earlier Citizen citizenOying = new Citizen (); citizenOying.displayCitizenDetails (); } // Finaly, the closing bracket for the class } // Note carefully that almost everything is enclosed in a pair of brackets // Remember always not to end class or method declaration in semicolon // The next thing to do is compile this program using the command: javac Citizen.java // Correct any syntax error if any and recompile. Then, run the program using the command: java Citizen /* You need to have the Java Development Kit installed in your Windows computer for you to be able to compile and run java programs. You can download it from the Sun Microsystems web site. It is about 20 megabytes download. If you buy a book on Java, make sure that a Cd-Rom containing the Java Development Kit is included. Just run the archived file and accept al defaults. Don't forget to include the JDK bin directory in your path environment statement using the msconfig command. Personalize the program using your own name and nickname. E-mail me if you experience problems. */