Instance variables

Instance variables in Java ar fields that are store on class level. They are non-static which means that they can only be reached in instantiated objects.
In other words, the value of a non-static instance variable can be unique for every object of that type.

Below is an example of an instance variable of type int. It is set to private which means it can’t be accessed from another class or object directly. The value of the instance variable can only be fetched through the method getSomeInstanceVariable, and only altered through the method setSomeInstanceVariable.

Search for more Java info on this site here:
Custom Search

Any thoughts or questions?