Java-Access Static Variables without Object

Access Static Variables without Object When a member is declared static, it can be accessed before any objects of its class are created, and without reference to any object. Static variables can be accessed directly by the class name and doesn’t need any object. Program Program Source class Data{ static int data1 = 40; static … Read more…

Java-Static Variables

Static Variables Let us assume that we want to define a member that is common to all the objects and accessed without using a particular object. That is, the member belongs to the class as a whole rather than the objects created from the class. Such members can be defined by static keyword. The members that … Read more…