Video: ClickMe
Output of Class or Static Variable by obj value =1
Output of Class or Static Variable by obj value =200
Output:
Output of Class or Static Variable value = 200Output of Class or Static Variable by obj value =1
Output of Class or Static Variable by obj value =200
ClassOrStaticVariablesInJava.java
package com.variables.tutorialbyexample;
public class ClassOrStaticVariablesInJava {
// Class or Static variable
public static int iClassOrStaticVarible = 1;
// Class or Static variable as final, we can't change the value and name
// must be in capital
public static final int I_CLASS_OR_STATIC_FINAL_VARIBLE = 200;
public ClassOrStaticVariablesInJava() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
// Class level access
System.out.println("Output of Class or Static Variable value = "
+ I_CLASS_OR_STATIC_FINAL_VARIBLE);
// New object creation of ClassOrStaticVariablesInJava
ClassOrStaticVariablesInJava obj = new ClassOrStaticVariablesInJava();
// Calling with obj
System.out.println("Output of Class or Static Variable by obj value ="
+ obj.iClassOrStaticVarible);
System.out.println("Output of Class or Static Variable by obj value ="
+ obj.I_CLASS_OR_STATIC_FINAL_VARIBLE);
}
}
Please like and share it!!!
No comments:
Post a Comment