Java Program Structure and First Program

Here we will see the structure of the java program and create a java first program in notepad and run it

1. Structure of Java Program

Let’s see the basic structure of the java program 


class- is write to create a class.

class_name – is the name of the class. It is an identifier.

public–  is an access modifier used for the main() method accessible for everyone.

static- class contains a main() method does not have an object and if we want an access a class without creating an object of that class then method main() must be declared as static.

void- is a return type. A Void denotes that the main() method return noting.

main()– main is a method from where the execution of the program starts.

2. Syntax to print statement


System: System is a predefined class, it is a final class in java.lang package

out:  is a static member of the System class and is an instance of 

println() or print(): is a method of Anything written inside the round bracket will be printed.

3. Simple java program to print Hello Students

Write java first program in notepad as given below

4. how to run java program in notepad and cmd

1 Open notepad and type the program open file then save this program with the name

How to save java first program in notepad

2. Goto the start menu and type ”cmd” and press enter to open the command prompt.

3. Use the cd command ( cd dir_name or .. to go up one directory) to navigate to the directory where the program is saved.

For example, is saved in a “document” folder of the c directory.

            c:>cd documents        [press enter]

4. for compile write (with file name) : javac                   // here javac is a compiler

5. run write (with class name): java HelloStudents        


What is the basic structure of java program

1. documentation
2. package declaration
3. import statement
4. class definition
5. main method definition