Java Programming
About Lesson

BASIC STRUCTURE OF JAVA PROGRAM

Here is a sample java program that displays a welcome message as output.

/*First Java Application*/

public class application

{

public static void main(String args[])

{

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

}

}

What is System.out.println?

System is a class of java.lang package

out is a static variable of System class of PrintStream type

println() is a method of PrintStream class

If any change in the syntax of main method, the program can be able to compile but at runtime you will get NoSuchMethodError: main Error

Acceptable changes to the main method in java program

The arguments of main method can be written in any of the following form:

String[] args

String []args

String args[]

String… args

String[]

The following additional modifiers are allowed in the header of main mehod

final

synchronized

strictfp

 

You cannot copy content of this page