First Program of JAVA
First Program of JAVA
CODE:
public class ClassNAme {
public static void main(String[] args) {
System.out.println("Welcome to Codezword");
}
}
After writing this code close your Editor.
Now open CMD or Terminal in your PC.
Write the following commands to execute the code.
Previous Page Next Page- First of all open your text editor & create file with .java extension.
- Here i am saving file as ClassNAme.java.
- Remember here name of the .java file & name of the class must be same.
- JAVA is case sensitive so ClassNAme & classNAme are different.
- main() method is mandatory method to execute the program.
- Generally class names are starts with Capital Letters & method names Starts with Small Letters.
CODE:
public class ClassNAme {
public static void main(String[] args) {
System.out.println("Welcome to Codezword");
}
}
After writing this code close your Editor.
Now open CMD or Terminal in your PC.
Write the following commands to execute the code.
- javac ClassNAme.java;
- java ClassNAme.java;
Here Your first Program runs successfully.
If you get error in this program please check following points
- File name & class name must be same.
- Method name must starts with Small Letters.
- Check semicolon because every statement must ends with semicolon.
0 Comments