• iconJava Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Java Syntax


class ClassName
public static void main(String args[])

In the above syntax
class: is a keyword.
ClassName: ClassName any uder defined name.
public static void main(): It is a main method or function.
public:public is a accessmodifier.
public means It runs anywhere(any Platform , any Processor)
static: Here static is a one time memory allocation

void: is a no return type.
String args[]: It is a String array.It is used to store the keyboard values.
System.out.println.: It is a output statement.
System: is a Class.
out: This is an instance of PrintStream type, which is a public and static member field of the System class.
println: is a method.

These output statements are classified into 2 types.

It is used to print the statements in a single line.
It is used to print the statements in a line by line.

Steps to write a java program
Step 1:
Open Notepad write the java program.

Step 2:
Save the Program with ClassName.java in any location

Step 3:
Path Setting:
1. Open MyComputer(This PC) open
C:Drive open
ProgramFile open
java open
jdk open
bin open
and copy bin URL:

2: Right click on MyComputer(This PC)
Advanced System Settings
Environment Variables
User Variables
Take a New Option
Varaible Name: path
Variable Value: Paste copied bin Path
Click On Ok
Ok Ok

Step 4:
Open Command Prompt and change the directory where the Java Program saved
cd foldername

Step 5: Compile the java program with the special syntax is
javac programname.java

Here javac is a compiler which is used to compile the java program and display the error in the program
If there is no error in the program it genarates.class file.

Step 5:
Run the java program
java programname.