Friday, 14th October 2011
Follow WikiJava on twitter now. @Wikijava

HelloWorld.java

From WikiJava

Jump to: navigation, search
The author suggests:

buy this book

The beginning of every programmer. Hello world is by (C) tradition the first program a programmer writes and the first program you execute when you install a compiler.

It gives an inside of the basic structures of the language and if you see on your screen the "hello world!!!" string it means that the compiler is properly installed and running.

Contents

the article

Hello world is the simplest program you can write that generates an output that you can see.

Note that even the "Hello world" in Java requires the definition of a class.

You can go as simple as putting a single method in the class, and that will be:

public static void main(String[] args) 

this is the default starting point of every Java program. A main method is always required and must always be written in this exact way.

inside the method you can finally insert your Java commands which, in this case, are limited to the

System.out.println("Hello World!!!");

Which prompts in the default output the string passed as parameter.

As you can see the comments are written between the /* and */ strings.

There are other ways to insert comments in Java the particular ones shown in this example will be interpreted to form the javadoc.

HelloWorld.java

Image:250px-Subversion.png
You can download the complete code of this article from the Subversion repository at this link

Using the username:readonly and password: readonly

See the using the SVN repository instructions page for more help about this.
/**
 * Hello World
 *  
 * @author Giulio
 */
public class HelloWorld {
 
    /**
     * 
     * Prints on the default output a greeting to the world.
     *  
     * @param args   
     */
    public static void main(String[] args) {
	System.out.println("Hello World!!!");
    }
 
}

Comments from the users

To be notified via mail on the updates of this discussion you can login and click on watch at the top of the page


Comments on wikijava are disabled now, cause excessive spam.