Monday, February 26, 2018

My first java application

import java.lang.System;
import java.lang.String;

class FirstApp

    static int a =100;
    float b = 7.9f;  //always use f constant with float values else you will get CTE
    static double d = 89.98;
   public static void main(String[] args)
   {   FirstApp f= new FirstApp();
  
    //STATIC variables can be Accessed in three ways, Recommed way using CLASS name.
     System.out.println("Ashutosh "+ a);  //DIRECT access
     System.out.println("Ashutosh "+ FirstApp.a);  //using CLASS NAME, RECOMMEDED way
     System.out.println("Ashutosh "+ f.a);   // using OBJECT REFERENCE VARIABLE
     System.out.println(f.b);
      System.out.println(d);
       //System.out.println(f.b);
     }
   
}

Thanks
Happy programming!

No comments:

Post a Comment

Sacred Thought

28 April 2024 Today I am going to explain verse 31 - 38 chapter two for you all. There is no opportunity better than a righteous war (सत्य औ...