Basics of Java (1) Prepared by Rushit Bhadaniya
Simple JAVA Program class one { public static void main(String[] arg) { System.out.println(“MY first Java Program“); } } Prepared by Rushit Bhadaniya
First Line [ class one ] •class one declares a class •Everything must be placed inside a class. •Class is KEYWORD Prepared by Rushit Bhadaniya
Opening Brace [ { ] •Every class definition in java begins with an opening brace “{” and ends with closing brace “}” Prepared by Rushit Bhadaniya
Main line [ public static void main(String[] arg) ] •This line contains 3 keywords •public • static • void Prepared by Rushit Bhadaniya
public • Public keyword is an Access specifier. • If Method has access specifier as public that means it can be accessible to all other classes. Prepared by Rushit Bhadaniya
static •Static keyword declare method as one that belongs to entire class not a part of any objects of the class. •Main must always be declared as static. Prepared by Rushit Bhadaniya
void •Void keyword states that the main method does not return any value Prepared by Rushit Bhadaniya
Output line •In c language we use printf(“ ”); •In c++ we use cout<<“ ”; •In java we have to use • System.out.println(“ ”); println is a member of the out object, which is static data member of System class. Prepared by Rushit Bhadaniya
Output line •In c language we use printf(“ ”); •In c++ we use cout<<“ ”; •In java we have to use • System.out.println(“ ”); println is a member of the out object, which is static data member of System class. Prepared by Rushit Bhadaniya
Save program as one.java
Compile and run source file
Thank You!!!

Basics of java (1)

  • 1.
    Basics of Java(1) Prepared by Rushit Bhadaniya
  • 2.
    Simple JAVA Program classone { public static void main(String[] arg) { System.out.println(“MY first Java Program“); } } Prepared by Rushit Bhadaniya
  • 3.
    First Line [class one ] •class one declares a class •Everything must be placed inside a class. •Class is KEYWORD Prepared by Rushit Bhadaniya
  • 4.
    Opening Brace [{ ] •Every class definition in java begins with an opening brace “{” and ends with closing brace “}” Prepared by Rushit Bhadaniya
  • 5.
    Main line [ publicstatic void main(String[] arg) ] •This line contains 3 keywords •public • static • void Prepared by Rushit Bhadaniya
  • 6.
    public • Public keywordis an Access specifier. • If Method has access specifier as public that means it can be accessible to all other classes. Prepared by Rushit Bhadaniya
  • 7.
    static •Static keyword declaremethod as one that belongs to entire class not a part of any objects of the class. •Main must always be declared as static. Prepared by Rushit Bhadaniya
  • 8.
    void •Void keyword statesthat the main method does not return any value Prepared by Rushit Bhadaniya
  • 9.
    Output line •In clanguage we use printf(“ ”); •In c++ we use cout<<“ ”; •In java we have to use • System.out.println(“ ”); println is a member of the out object, which is static data member of System class. Prepared by Rushit Bhadaniya
  • 10.
    Output line •In clanguage we use printf(“ ”); •In c++ we use cout<<“ ”; •In java we have to use • System.out.println(“ ”); println is a member of the out object, which is static data member of System class. Prepared by Rushit Bhadaniya
  • 11.
  • 12.
    Compile and runsource file
  • 13.