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

5 May 2024 Hari Om Verse 50-51, chapter two:  In this chapter two Shree krishna explains a simple way of living. Free from desires and void ...