Sunday, 19 August 2012

Java Basic


Introduction of Java Basic



Rules for class declarations
  1. Class Names For all class names the first letter should be in Upper Case.
  2. Method Names All method names should start with a Lower Case letter.
  3. Program File Name Name of the program file should exactly match the class name.
  4. public static void main(String args[]) java program processing starts from the main() method which is a mandatory part of every java program.
Example :

public class DemoProgram{

    public static void main(String []args){
    
        // write your code
    }
} 

Environment Setup
  1. Windows
    • Right-click on 'My Computer' and select 'Properties'.
    • Click on the 'Environment variables' button under the 'Advanced' tab.
    • Click on Path variable
    • Append Path variable's value by adding this line
      ;c:\Program Files\java\jdk\bin
Compile and Run java program
  1. First point to your java bin directory by using cmd
  2. Then use following command to compile

    javac filename.java
  3. Then run program using following command

    java filename.java

No comments:

Post a Comment