First time here? Checkout the FAQ!
menu search
Describe the typical java program structure.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

Best answer
Any java program can be written using simple text editor like notepad or

WordPad. The file name should be same as the name of the class used in the

corresponding java program. The extension of the file name should be .java.


This is my First Java Program


class FirstProgram


public static void main(String args[])


System.out.println(“This is first program”);




In our First Java program, on the first line we have written a comment

statement.This is a multi-line comment.

Then actual program starts with class FirstProgram

Here class is keyword and FirstProgram is a variable name of the class. The

class definition should be within the curly brackets. Then comes

public static void main(String args[])

This line is for function void main().The main is of type public static void.

Public is a access mode of the main() by which the class visibility can be defined

Typically main must be declared as public.

The parameter which is passed to main is String args[]. Hence String is a

class name and args[] is an array which receives the command line arguments

when the program runs,

System.out.println(“This is first program”);

To print any message on the console println is a method in which the string

“This is first program” is written. After println method, the newline is invoked.

Java program is a case sensitive programming language like C or C++.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike