Skip to main content

Posts

Showing posts from 2014

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...

static keyword in Java

The  static keyword  is used in java mainly for memory management. We may apply static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class. The static can be: variable (also known as class variable) method (also known as class method) block nested class 1) static variable If you declare any variable as static, it is known static variable. The static variable can be used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc. The static variable gets memory only once in class area at the time of class loading. Advantage of static variable It makes your program  memory efficient  (i.e it saves memory). Understanding problem without static variable class  Student{         int  rollno;        String...