/*
 * File: p01.java
 *
 * Description:  This example program will show the most
 *       (or at least one of the most) basic java apps.  Each succeeding
 *       app will build on the previous one getting more and more
 *       complex until I fall over.  This first is the usual
 *       "Hello, world!"
 *
 * Modifications:  11/1/95 CValcarcel Created.
 *
 * NO WARRANTY, EXPRESSED OR IMPLIED, BLAH, BLAH, BLAH.
 *
 * THIS IS EXAMPLE CODE AND SHOULD NOT BE USED FOR ANYTHING
 * EXCEPT INSTRUCTIONAL PURPOSES.
 *
 */

//
// "class HelloWorld" implies "class HelloWorld extends Object".
// All classes in Java derive from class Object unless the
// keyword extends is used explicitly.  We aren't doing anything
// fancy so we don't need to state any "extends".
//
class HelloWorld {
     // "public static void main( String args[] )" is certainly
     // a mouthful!  Let's take it one at a time:
     //
     //     public:  as main() is, by definition, what java
     //              will try to run when it finds this class
     //              this function must be visible and public
     //              makes that possible.  If the keyword "public"
     //              is missing the java compiler (javac) will
     //              complain that main must be public and static.
     //     static:  there must only be one main() per Java application
     //              (sound familiar?).  However, it is conceivable
     //              that someone might take this class and subclass
     //              off it to create a new version.  No, no!  main()
     //              is a one shot deal.  Marking it static guarantees
     //              no subclassing allowed (of course, since the
     //              compiler appears to know about main() to begin
     //              with why not just take care of it automagically?)
     //       void:  In Java main() always returns nothing.  It must
     //              always be tagged as void.  The only calls that
     //              can't be tagged are constructors.
     //       main:  there can only be one per application (highest
     //              level class) and it will always get an array of
     //              Strings which will contain any incoming arguments.
     //              The arguments do not work the same as in C.  args[0]
     //              does not contain the name of the application
     //              being run;  it contains the first argument to the
     //              application.
     //
     public static void main( String args[] )
     {
         // System is a very interesting class in Java.  It is
         // marked "final" (you cannot subclass it) and it has
         // no constructors so you cannot instantiate it.  However
         // it is probably one of the more useful classes in the
         // Java libraries because it allows you to perform some
         // of the more basic tasks with minimal pain.
         //
         // "out" is a static variable in the System class and it
         // contains the output PrintStream (the class where println()
         // can be found).
         //
         // println() takes a number of different argument types
         // and will even do formatting on the fly.  In any case, it
         // doesn't return anything and doesn't explicitly throw anything
         // (underneath the hood is another story.  write() can throw
         // either an InterruptedIOException or an IOException.  Is it
         // a good idea to catch those, or even just a plain vanilla
         // Exception?  Probably, but I have yet to see any code
         // that does that.  Let the Coder Beware).
         //
         System.out.println( "Hello, world!" );
     }
}

