Core Java Tutorial

Instance and Class Members

Java has static keyword to create fields and methods that are members of the class rather than to an instance of the class.

Class Variables

When we create multiple objects out of a class, each object has it’s own distinct copy of instance variables. For eg. when we create multiple employee object out of Employee class, each object will have it’s own copy of member variables, ie name, age and salary etc.

There are situations when you want to have variables that are common to all Objects. This is achieved using “static” modifier in Java.

Advertisements

, , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: