Skip to main content

Posts

Showing posts with the label Java Variables

Java Variable Declarations

Depending on the Content Holds by variable they are divided into TWO categories 1.     Primitives Variable:   A primitive can be one of eight types: char, boolean, byte,short, int, long, double, or float. Once a primitive has been declared, its primitive type can never change, although in most cases its value can change. 2.       Reference variables A reference variable is used to refer to (or access) an object. A reference variable is declared to be of a specific type and that type can never be changed. Reference variable can be used to hold object references. Ex: String string1=”Sekhar4J”; Here string1 is a String object Primitive variable ca n be used to hold primitive values. Example:   int i=10; int[][] a={{1,2},{3,4,5},{6,7,8,9},{}}; for(int i=0;i  <= a ;i++)   System.out.println(a[i].length); } output: 2,3 ,4,0 Depends on the position at which it is declared all the variables divided into 3 categories...