Thursday, February 12, 2015

Final

When a variable is declared as final it remains constant and it cannot be changed. For example consider the name of the company which will never change for any of the employees so this can be defined as final and the value remains same throughout the execution. Let's consider the same example defined in Static section.

AboutStaticVariable.java

public class AboutStaticVariable {

 final static int companyname = "Google";//Defined the class Variable static and final

 public static void main(String args[]) {

  System.out.println(companyname);
  companyname="Apple";//I cannot change this variable value since it is defined as final
 }

}


>>>Primitive Date Types
------------------------------------------------------------------------------------------------------------