A "Hello, World!" is a simple program that
outputs Hello, World!
on the screen. Since it's a very simple
program, it's often used to introduce a new programming language to a newbie.
Let's
explore how Java "Hello, World!" program works.
If you want to run this program on your computer, make sure that
Java is properly installed. Also, you need an IDE (or a text editor) to write
and edit Java code. For that, check How to run Java on your computer?
Java "Hello, World!" Program
// Your First Program
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Output
Hello, World!
Note: If you have compiled the exact code, you need to save the file as HelloWorld.java
. It's because the name of the class and file name should match in Java. To learn more, visit Why are filename in Java the same as the class name?
Also, some online compiler only accepts the class named Main
.
0 Comments
If you have any doubts,please let me know