/*
First Java Program */
1. Print
Hello World using Java Program.
class HelloWorld
{
Public
static void main( String args[] )
{
System.out.println(
" Hello World..!!! ");
}
}
-
Save
the file with HelloWorld.java in any folder. ( You can use any name for the
file, but need to execute with class name only ).
-
Open
cmd. ( Goto Run, type cmd)
-
Compile
& Execute the application as follows:
Javac is used to compile the
application.
Java is used to execute the
application.
Program Explanation:
Ex1: Hello
Ex2: HelloWorld
Description about main():
Main is defined as public because
to give permission to JVM to call it.
Main is defined as static because
the JVM can call it without object creation.
It is declared as void because,
JVM doesn't need any response back from main().
Main contains args[] as parameter
because it provides the facility to input variables from command prompt.
Compiling and Execution:
No comments:
Post a Comment