STATIC KEYWORD


STATIC KEYWORD

In a class we can have 2 types of members.

i.  Instance members – represents attributes and behavior of individual objects.
ii.    Class members – represents attributes and behavior of the whole class.






To understand where we need to use static, see the diagram below-







v  By default all the members of a class are instance members. In order to associate a member of a class static keyword is used.

v  static denotes execution of whole class.


Syntax of compiling –

javac NameOfSourceFile





example - 














No comments:

Post a Comment