Today, I am going to write a simple basic HelloWorld Program code in java. It is the most simplest program. It will just display a message like "Hello World" on the command screen after execution.
Let me first tell you about the default package. In java there is a default package named as java.lang. & can be imported by this code import java.lang. . This package is default and it is included automatically by default even if you do not declare it in the code.
Now, Let us code the program :-
import java.lang.*; // default package class HelloWorld { public static void main(String ar[]) { System.out.println("Hello World"); } }
How to execute the program ?
- Save as: E:\HelloWorld.java
- Open cmd: Run -> cmd
- Compile: E:\> javac HelloWorld.java
- Execute (interpreter): E:\> java HelloWorld
Output:
[alert-announce]Hello World[/alert-announce]
Journey of a Java program from Source code to Output
I have given a flow chart of java program below. It is actually the flow of execution of program including compilation and interpretation. It will help you understand that how we get output finally from initial source code.
Source code [HelloWorld.java] ---> javac [Compiler] ---> Byte code [HelloWorld.class] ---> java [Interpreter] ---> [Output]
SignUp Now to Get FREE Access to our All in One Digital Marketing Platform!
We will continue to update Front; if you have any questions or suggestions, please contact us!
Follow us on Facebook, Instagram, Twitter, Pinterest, Linkedin, YouTube, and Medium.
erbhaveshkumar123
I create advanced website builders made exclusively for web developers.
3 Comments
As a Special Education teacher this resonates so well with me. Fighting with gen ed teachers to flatten for the students with learning disabilities. It also confirms some things for me in my writing.
ReplySince our attention spans seem to be shrinking by the day — keeping it simple is more important than ever.
ReplyPost a comment
Stay in the know
Get special offers and the latest news updates from ElanceMarket™.