Talk:Java Training Course/JT02

From tehowiki
Revision as of 18:43, 22 September 2017 by imported>Gfis (new)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

An almost minimal Java program is:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    } // main
} // HelloWorld

It must be stored in a file HelloWorld.java, since Java source files must have the same name as the class contained in it.

Upper/lowercase letters are (very) important in Java.

For the separation of words in Java names, underscore characters would be possible, but they are deprecated. The CamelCase convention of embedded uppercase letters is used instead.

The program is compiled into a file HelloWorld.class by

javac HelloWorld.java

The classfile maybe run by

java HelloWorld

It will output the desired text:

Hello, World!