First Program of JAVA 


  • 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 
  1. File name & class name must be same.
  2. Method name must starts with Small Letters.
  3. Check semicolon because every statement must ends with semicolon. 


Previous Page                                                                                                     Next Page

0 Comments