Online Software Educational Training - IT Tutorials - Online Education Training for Computer Software


Home

JAVA PROGRAMMING

A Closer look at the First Program

Although hello.java is quite short, it includes several key features which are common to all Java Programs. Let's closely examine each part of the program.

The programs begin with the following lines:

/* This is Comments 

This is a simple Java program call this file "hello.java".

*/



This is a comment. Java lets you enter a remark into a program. The contents of a comment are ignored by the compiler.


class hello {

This line uses the keyword class to declare that a new class is being defined. hello is an identifier that is the name of the class.


public static void main(String[] args) 


This line begins the main() method. All Java applications begin execution by calling main(). The public keyword is an access specified, which allows the programmer to control the visibility of class members. The keyword static allows main()  to be called without having instantiate a particular instance of the class.  The keyword void simple tells the compiler that main() does not return a value. String args[ ] , declares a named args, which is an array of instances of the class String.

System.out.println("Hello World, You are welcome");

This line outputs the string "Hello World, You are welcome." followed by a new line on the screen.

 


Previous

Next