mathajax

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.
    1. void - specify return type of the function. the main function's return-type must be void (no return value)
    2. 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).
    3. 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

Popular posts from this blog

Matrix Forward and Back Substitution

Solving System of Linear Equations by Gauss Jordan Elimination

Solve System of Linear Equations by LU Decompose

Distance Metric - Euclidean Distance

Matrix in Java