User Rating: / 0
PoorBest 

Hello JavaWorld

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.

The default sample

package biz.ritter.java; 
/**
* Title: Make Java - How To
* Description: A simple 'Hello World' - Application
* Copyright: Copyright © 2009
* Licence: BSD
* @author Sebastian Ritter
* @version 1.0.0.0
*/

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
}

Object-oriented

package biz.ritter.java;
/**
* Title: Make Java - How To
* Description: An object-oriented 'Hello World' - application
* Copyright: Copyright © 2009
* Licence: BSD
* @author Sebastian Ritter
* @version 1.0.0.0
*/
public class HelloWorldOO {
  /** 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 other way

package biz.ritter.java;
/**
* Title: Make Java - How To
* Description: An other way for 'Hello World' - application
* Copyright: Copyright © 2009
* License: BSD
* @author Sebastian Ritter
* @version 1.0.0.0
*/
public class HelloWorldStatic {
/** This static block is calling, when our class HelloWorldStatic
* is loading from Java Virtual Machine [JVM].
*/
static {
System.out.print ("Hello World - an other version");
}

  /** 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);
}
}