Posts

Showing posts from January, 2015

Static In Java!

Static in dictionary means stable,unchanging or inactive. In java static is generally used in case of variables,Methods,blocks and classes. It is not associated with any instance of the class that is why you can access the static member without creating any instance of the class. 1.Static variables:  When a class has static variables,those are likely to be called class variables.They don't need instances of the class to be created and then values to be initialized seperately.These can be directly accessed by className.variableName. When you have the common data for all the objects/instances. Then you might be allocating an extra memory for the same variable for every instance you create. Ex1: When a company Xyz has its employee data stored in a class.he knew that everyone are of the same company . Here it creates an extra allocation for all the instances. public class Employee(){ String Name; String Company; long Salary; Employee(String Name,long Sa