Pages

Sunday, September 30, 2012

Java "Hello World" Program

w7r.blogspot.com

Traditionally, "Hello world" is the first program created in any programming language by new users to ensure they are able to compile and run their program in the given language. So I thought it'd be a good idea to post up the code for HelloWorld.java on the site for java beginners.

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

Breaking Down The Code

System.out.println(string)
This statement (or line of Java code) informs the System to print the string (or text referred to by the variable, string) to the console (where output is displayed).
"Hello, World!"
is a string literal. String literals are text that are actually written and displayed exactly as the programmer wrote them. You could replace the text inside the quotation marks with anything you would like to be outputted to the console.

No comments:

Post a Comment