Java Program Structure

/Name of this file will be “Hello.java”

public class Hello

{

public static void main(String[] args)

{

System.out.println(“Hello Java”);

}

}

1. public class Hello – creates a class called Hello

2. {…} – group all the commands

3. public static void main – main method is declared public, static used when we want to access a method without creating its object, void indicates that a method does not return a value. main is a method indicates starting point of a Java program.

4. String[] args – It is an array where each element of it is a string, which has been named as “args”.

5. System.out.println(); – used to print text on the screen as output, where the system is a predefined class.

Leave a Reply