Sunday 22 February 2015

What does the static keyword mean, and where can it be used?

Static can be used in four ways:

  • static variables are shared by the entire class, not a specific instance (unlike normal member variables)
  • static methods are also shared by the entire class
  • static classes are inner classes that aren’t tied to their enclosing classes
  • static can be used around a block of code in a class to specify code that runs when the virtual machine is first started up, before instances of the class are created.

No comments:

Post a Comment