Start java program from Hello World
The Hello world Java program has a main function, in which an object of OutputStream to print string (Hello World) from program to computer monitor.
Java main function
- A Java program or application must have a main function.
- The Java interpreter starts execution from the main function.
- The main function must be defined with the following keywords.
- void - specify return type of the function. the main function's return-type must be void (no return value)
- static - it specify that the main function must be accessed class-name. (The Java interpreter does not need to initialize an object to the class having the main function).
- public - it specify that the main function can be accessed from outside of the class.
- The file having the main function should be saved as the class-name.
- System - A final class provides system properties, process features and I/O objects.
- out - An object of the OutputStream provides print member functions to connect output device.
- println - A member function the object, out prints string (message) on the output device (default computer monitor).
Jave program - Hello World
The Hello World program prints the message "Hello World" on display screen
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World");
}
}
Output
Hello World
Comments
Post a Comment