First Java Program | HelloWorld by TechnoNiit
In this article, we will learn how to write HelloWorld program of java. We can write a simple HelloWorld java program easily after installing the JDK.A "HelloWorld!" 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.
For executing any java program, you need to
- Install the JDK if you don't have installed it, download the JDK and install it.
- Set path of the jdk/bin directory.
- Create the java program
- Compile and run the java program
//First way To Print HelloWorld Program in java
class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello Java");
}
}
//Second way To Print HelloWorld Program in java
public class HelloWorld
{
public static void main(String args[])
{
String s = HelloWorld;
System.out.println(s);
}
}
If you have copied the exact code, you need save the file name as HelloWorld.java. It's because the name of the class and filename should match in Java.
To compile: javac HelloWorld.java
To execute: java HelloWorld
You May Also Like:
WAP that Sum of Two Number
WAP that Subtract of Two Number
That’s it. Now you have successfully print HelloWorld Program. If you have any doubt or question comment down below.
If you want to see the video of First Java Program, then watch the video below.
I hope this post will useful to you, Thanks For Visiting, Keep Visiting
No comments