//Comments begin with a “//”.  Note that all keywords are written in red

//in the comments.

 

 

//*******************************************************************

// Lincoln.java         Author: Lewis and Loftus

//

// Demonstrates the basic structure of a Java class

//*******************************************************************

 

//the Java interpreter or compiler ignores all of the characters after “//”

//the syntax for a class definition is “modifer class class-identifer”.  In

//this case, the modifer is public and the identifier is “Lincoln”.

//Identifiers like “Lincoln” are chosen by the person who writes the

//program, but the name chosen must follow the rules of Java.

//public means that the whole world has access to this class.

 

 

 

public class Lincoln

{           //Again, notice that the class is contained in

            //a opening brace “{“ and

            // a closing brace “}”

 

      //---------------------------------------------------

      //    A class to print a presidential quote

      //---------------------------------------------------

 

            //A method has the format modifier returnType identifierName.

            //The modifier is public, meaning it is accessible to the

            //world.  It does not return anything, so it has the void as

            //the return type. void means nothing is returned.

 

            //The String[] args are the parameters passed to this method.

 

      public static void main(String[] args)

      {           //the definition of the method “main is

                  //also contained between “{“

                  // and “}”

 

      //---------------------------------------------------

      //    Calls method to print a presidential quote

      //---------------------------------------------------

 

            quote();

      }

 

      private static void quote()

      {     //The method’s definition is contained between

            //the opening brace “{“ and

            //the closing brace “}”

 

            System.out.println("A quote by Abraham Lincoln:");

 

            System.out.println("Whatever you are, be a good one.");

      }

}

 

//The System.out.println is a call to a Java supplied class (an API)

//”System”, which contains a class of type PrintStream called “out”, which

//has a method called “println”.  This sends whatever is in the quotes

//to the standard output, which is the console window.

 

//So “System.out.println” is a simple way for the program to communicate

//with the outside world.  It sends output to the console window.  It

//only sends “Strings” to the outside world. 

 

 

 

 

 

//Insider the class we have a method, whose name is “main”.

//All java programs start at the method called “main”, so there can

//be at most one method called “main” in a Java program.

//The modifier static attached to the method “main” signifies that

//“main” is a class method and is not attached to any object. 

 

//Finally, the method “quote” is called from the method “main”. It

//is also static because a static method may only call another

//static method, and not a non-static method. A non-static method

//is a method which only belongs to an object of the class.  The

//reason a static method can not call a non-static method, is that

//the compiler wouldn’t know which object the method belongs to.

//“quote” returns nothing so its return type is void, and it is private.

//A private method is one that only members of the class have access

//to it, and not the outside world.  The method “quote” then prints

//out the quote from Abraham Lincoln.