Structure of Java Program
class ClassName {
public static void main(String args[]) {
//statements
}
}
Let's look at the elements involved in the structure of a Java program.
A typical structure of a Java program contains the following elements:
class Block:- Methods and Variables can be written in class Block
Methods Block:- Statement and instructions written in method block
*Steps to Create, Complie and execute java Program *
Stpe-1. Write A programm using editor and IDE
Editor : -
1. Notepad
2. Word
3. Notepad++
4. Edit plus
5. Sublime
IDE:-
1. Eclipse
2. Intelji
3. Visual Studio code
4. Net Beans
Using the above code editor we write programs and save the file using .java extension
Step-2. Compile the code or complie the java file
complier complie the code complier check's for the syntax(rules) if the syntax is correct is generated the class file if the syntax's is wrong it does not generate the class file but its throw complie time error
Step-3. excute the class File
Syntax of print Statements
- System.out.println();
- This print statement will print the data as push the cursor to next line
- System.out.print(); This Print Statement will print the data and cursor will stay in same line
Now Write The below code in any editor
class MyProgram {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
Command to complie java program
javac MyProgram.java
command to excute java program
java MyProgram
Note:- To check the version of JDK
javac -version
Top comments (0)