The Java "Hello World" Program.
The purpose of this program is to simple output the text "Hello World!" to the screen. Here is the code to do just that.public class HelloWorld
{
public static void main (String[] args)
{
System.out.println("Hello World!");
}
}
========================================================================
Adding Comments to the Program.
Comment are essential to programming as they allow you define your program, explain clearly to other programmers what you are doing and of course remind yourself where you are and what you where trying to finish last Friday night.There are two types of Comments in Java:
The Single-line Comment ; //
// -Normally added at the end of the line of code.The Multi-line Comment; /**/
/** Normally added above the code to be commented.
*/
Hello World Program with Comments
/** This program will display the text "Hello World!" to the screen.
*/
public class HelloWorld
{
public static void main (String[] args)
{
/*
* First call the System Class.
* Then call the .out Method.
* Display the message using the .println Method.
*/
System.out.println("Hello World!"); // Message to be displayed
} // end of the main method.
}// end of the HelloWorld class
No comments:
Post a Comment