Java is very powerful and secure language with multiple features. Writing a java program is a very simple method. Here is the syntax of a simple java program
class name
{
public static void main (String arg[])
{
// body.
}
}
here “name” is the name of class and you will save your program with this name. You can write anny name of your class but not reserve words of java. The function “public static void main (String arg[])” is java’s main function.
Remember you must save your program like this:
"class-name.java"
otherwise it will not execute/compile.
“body” means the code of your java program.
class name
{
public static void main (String arg[])
{
// body.
}
}
here “name” is the name of class and you will save your program with this name. You can write anny name of your class but not reserve words of java. The function “public static void main (String arg[])” is java’s main function.
Remember you must save your program like this:
"class-name.java"
otherwise it will not execute/compile.
Note:
java is case sensitive language and you have to write the main function as it is written above.“body” means the code of your java program.