class HelloWorld {
public static void main(String[] args)
{
System.out.println("Hello World!"); // Display the string on a new line.
System.out.println("- Nimish Prabhu");
}
}Firstly,
The name of the class in which main() method exists should have the name same as the file name.
In this case : HelloWorld
It is case sensitive.
System.out.println() is used to print a message on a new line.
If you want to print message on same line you can use System.out.print()
public static void main(String[] args)
The main method accepts a single argument: an array of elements of type String.
This array is the mechanism through which the runtime system passes information to your application. For example:
java MyApp arg1 arg2
Each string in the array is called a command-line argument.
0 comments:
Post a Comment