Java Online Training In Andhra Pradesh and Telangana
9010519704
Opening Hours :7AM to 9PM
Java Syntax
Syntax
class ClassName
{
public static void main(String args[])
{
System.out.println("Welcome");
}
}
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.
Here 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.
Here 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.
Here:
These output statements are classified into 2 types.
1.print
2.println
print:
It is used to print the statements in a single line.
println:
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)
Properties
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 Syntax:
cd foldername
Step 5:
Compile the java program with the special syntax is Syntax:
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 Syntax:
java programname.