The programm Hello World is the default application to show us how we use the simple parts from a (new) programming language. And so we take more than one look at Java.
public class HelloWorldSimple { /** The first method for Java application is: * public static void main (String [] arg) {} * final call we do not change the arg variable. * This discription is a Java comment for tool javadoc. * @param String [] parameter - here ignored */ public static void main (final String [] ignored) { /* Die follow line display the sentence. This is a multi line comment. Tool javadoc ignore these. */ System.out.println ("Hello World say's Bastie!"); // An end of line comment } }
/** The first method for Java application is: * public static void main (String [] arg) {} * final call we do not change the arg variable. * This discription is a Java comment for tool javadoc. * * With keyword static the method is defined as class method. * Class methods can be called without creating object instance. * @param String [] parameter - here ignored */ public static void main(final String [] ignored) {
/* Create an object and set variable helloWorldOO with reference to these instance */ final HelloWorldOO helloWorldOO = new HelloWorldOO ();
/* Call the method at our object and give needed parameters. */ helloWorldOO.say ("Hello World.\nJava is object-oriented!\n"); }
/** Our self defined method 'say' display the text on console. * @param String parameter with text to display */ public void say (final String text){ /* Display given text */ System.out.println (text); } }
/** The first method for Java application is: * public static void main (String [] arg) {} * final call we do not change the arg variable. * This discription is a Java comment for tool javadoc. * @param String [] parameter - here ignored */ public static void main(final String [] ignored) { /* We leave our application and th JVM with this method.*/ System.exit (0); } }