Hello World in Java
-
date_range 27/06/2020 00:00 infosortJavalabelJava-tutorials
Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
NOTE: The class and and file name should be same while writing JAVA program. please make a note that in case you do not have a public class present in the file then file name can be different than class name. It is also not mandatory to have a public class in the file.
My First Program in Java:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!!!!!");
}
}
Output:
Hello World!!!!!
Explanation:
public class HelloWorld- Class definition:This line uses the keyword class to declare that a new class is being defined.
public static void main(String[] args)- main method: In Java programming language, every application must contain a
mainmethod. - public: So that JVM can execute the method from anywhere.
- static: Main method is to be called without object. The modifiers public and static can be written in either order.
- void: The main method doesn’t return anything.
- main(): Name configured in the JVM.
- String[]: The main method accepts a single argument an array of elements of type String.
- main method: In Java programming language, every application must contain a
System.out.println("Hello World!!!!!");- This line outputs the string “Hello World!!!!!” followed by a new line on the screen. Output is actually accomplished by the built-in println() method. System is a predefined class that provides access to the system, and out is the variable of type output stream that is connected to the console.
