A class determines the types of data that an object can contain, as well as the actions it can perform

An object of a class is named or declared by a variable of the class type:

  • ClassName  classVar;

The new operator must then be used to create the object and associate it with its variable name:

  • classVar = new ClassName();

These can be combined as follows:

  • ClassName classVar = new ClassName();

Instance variables can be defined as in the following two examples

  • Note the public modifier (for now):
    • public String  instanceVar1;
    • public int  instanceVar2;

In order to refer to a particular instance variable, preface it with its object name as follows:

  • objectName.instanceVar1
  • objectName.instanceVar2

StringTokenizer Class