Static Elements

  • Eclipse: Oxygen
  • Java: 1.8

Static Elements:

Java allows you to access static members, static members are class level and can be accessed directly without any instance. For example. The static keyword means that the variable or function is shared among all the instances of that class since it belongs to the type, not to the real objects themselves.

The implementation of a static variable is shown here. The basic concept of a static variable is that it has a single reference variable.

In this way, the utilization of such variables should be possible to keep up a basic count of created objects or objects that access a class.

Output

Current variable value: 0
Current variable value: 1
Current variable value: 24

 

Output

Current variable value: 0
Current variable value: 1
Current variable value: 24

 

Contributed by: Poonam Tomar


VIEW COURSES

Buy me a coffee!

 

PayTM QR (INDIA)

  • Get video tutorials
  • Project files set
  • Get┬áCertified

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu