Java Things:
Variables, Classes, & Methods

Java is an object-oriented language. Hence, the emphasis is on things and the methods that manipulate those things. In the discussions that follow, four types of things will be discussed: primitive types, classes, subclasses, and packages.

You may wish to review the Introduction to O-O Programming in Java and Java Overview discussions. The first provides a general conceptual view of o-o programming and the second describes the basic frameworks for Java applications and applets. Familiarity with both topics will be assumed.


Primitive types

Unlike programming languages, such as Smalltalk, in which everything is an object, Java includes eight so-called primitive data types that are not, strictly speaking, classes and hence are not instantiated as objects. These eight types are discussed and illustrated here.

Classes

Classes comprise the second major category of types. To function as types, classes must first be defined and then used to declare variables of their respective types. When instantiated, these variables become objects that are instances of their respective class types.

Subclasses

Classes may be extended to create subclasses. All of the variables and methods of the parent class (superclass) are inherited by the subclass, although they can be redefined (overriden) in the subclass.

Packages

Packages are class libraries that may be imported and used in building programs. Much of the function associated with the Java language is actually provided by one or more packages. Examples include user interface components, networking support, and even basic input/output function.

References

References useful for this discussion include the following::