Structure of Java Program

roshan_100kar

Roshan Shambharkar

Posted on September 24, 2022

Structure of Java Program

Structure of Java Program

class ClassName {
 public static void main(String args[]) {
 //statements
 }
}
Enter fullscreen mode Exit fullscreen mode

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

  1. System.out.println();
    1. This print statement will print the data as push the cursor to next line
  2. 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!");
  }
}
Enter fullscreen mode Exit fullscreen mode

Command to complie java program
javac MyProgram.java

command to excute java program
java MyProgram

Note:- To check the version of JDK
javac -version

💖 💪 🙅 🚩
roshan_100kar
Roshan Shambharkar

Posted on September 24, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related