Few words about first Java program
Cool tip- Before starting running race in Java coding we need to understand basic things about first java program.
- So, please be attentive.
- By using class keyword we will create user defined class.
Sample
- Sample is a user defined class name in program.
public
- public is a keyword, it is an access modifier, it is visible to all
- static is a keyword.
- If we declare any method as static, it is known as static method(we will learn much in upcoming chapter provide link here).
- The core advantage of static method is that there is no need to create object to call the static method.
void
- void is keyword used for method level to tell the method is nothing returning
main(String[] args)
- Program execution starts from main method
- String[] args is used for command line argument. We will learn it later
System.out.println() :
- prints statement or data on console.
Flow in simple
- We need to compile .java program by using javac command.
- While compiling Compiler will create corresponding .class file for .java program.
- .class file contains byte code instructions which is not understandable by computer processor to display the output.
- Now we need to run .class file by using java command.
- Then while running the JVM will converts byte code instructions into machine understandable format to see the output.
- Now its time to celebrate the output of first java program, just have coffee and come back to start running race in coding.
- Nireekshan