- Main.java
Public class Main{
Public static void main(string[] args){
System.out.println("Hello World");
}
}
Output:-
Hello World
Every line of code that runs in java must be inside a class. in example we named the class Main. A class should always start with an uppercase first letter.
Java is case-sensitive:"MyClass" and "myclass" has different meaning.
The name of the java file the java file must match the class name.When saving the file, save it using the class name and add ".java" to the end of the filename.
Let's we have a explain main method:
The main Method
The main() method is required and you will see it in every java program:
public static void main(string[] args)
Any code inside the main() method will be executed, Dont't worry about the keywords. before and after main. You will get to know them bit by bit while reading this tutorial.
System.out.println()
inside the main() method, we can use the println() method to print a line of text to the screen:
public staic void main(string[] args){
System.out.println("Hello Guys, Welcome To My Blog");
}
0 Comments