Java Static Keyword Introduction

  • It is a non-access modifier
  • Static keyword can be applied to an instance variable or method.
    • Applying to an instance variable makes that variable as a class variable.
    • Both primitive and reference variable can be marked with static keyword
  • Static member
  • Static member belong to the class rather than to any particular instance, i.e.) it is used independently of any object of that class.
  • Static member is created using static keyword.
  • When a member is declared static, it can be accessed before any objects of its class are created, and without reference to any object.

The best example of a static member is main() method. main() should be called before any object exists , hence it is declared as static.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.