Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Class

The concept of class is fundamental construct upon which Java is built. A class serves as a blueprint or a
template for a certain type of object. Against this background all data types other than the primitive type
or the array must be addressed in terms of a class. This is evident in the way that we use a class. For
instance, going back to the class areaAndCircumference. In order to use this class we had to declare
variables of the type:

areaAndCircumference circle1;

Notice that this declaration follows the definition of how to declare primitive data type. This construct
implies that the identifier areaAndCircumference is a type and circle1 is an identifier of that type.

Standard Packages

Java has a vast and rich collection of classes. These classes are reposited in respective directories and
subdirectories. Each directory or subdirectory is called, a package. Programmers can use these classes in
their specific applications. There are several packages in Java. Two of the most important packages in
the language are java and javax. Figure 3.15 shows these packages and along with their sub-packages. In
our study we will focus on the package java and in particular the sub-package called lang.
Figure 3.15 Java packages and sub-packages.

Figure 3.15 shows Java’s two most important packages, namely java and javax. Most of the classes
found in the package javax and its sub-packages are designed to be used for Graphical User Interface
(GUI) programming. We will be using the class JOptionPane from javax for input and output later in
this course of study.

As we have seen from the figure, the package java contains several sub-packages. Some of these sub-
packages contain sub-packages also. The most important package in the Java language is the package
called lang. It is so important that its content is automatically loaded in memory when the Java compiler
is invoked. For all other classes, the package must be imported, using the import statement. The
following section explores the package java.lang.

The Package java.lang

As was mentioned earlier, the java.lang package contains classes that are fundamental to Java. All of the classes are available in
your program automatically. That is, as soon as the Java compiler is loaded, all of these classes are loaded into every Java source
file. Figure 3.16 shows java.lang two sub-packages and all the classes that are directly in the package java.lang.

There is no intention for you to memorize the classes in this package, but over time you will get to know them by name and their
intended purpose.

You might also like