#

| Chapter 25 |

# 25. The java.lang Package

Contents:
Select a new section and then

The `java.lang` package contains the classes that are most central to the Java language. As you can see from Figure 25.1, the class hierarchy is broad rather than deep, which means that the classes are independent of each other.

#### Figure 25.1: The java.lang package

`Object` is the ultimate superclass of all Java classes and is therefore at the top of all class hierarchies. `Class` is a class that describes a Java class. There is one `Class` object for each class that is loaded into Java.

`Boolean`, `Character`, `Byte`, `Short`, `Integer`, `Long`, `Float`, and `Double` are immutable class wrappers around each of the primitive Java data types. These classes are useful when you need to manipulate primitive types as objects. They also contain useful conversion and utility methods.

`String` and `StringBuffer` are objects that represent strings. `String` is an immutable type; `StringBuffer` may have its string changed in place.

`Runtime` provides a number of low-level methods associated with the Java run-time system. `System` provides similar low-level system methods. All the `System` methods are class methods, and this class may not be instantiated. `Math` is a similar class that supports only class methods--its methods provide floating-point math support.

The `Thread` class provides support for multiple threads of control running within the same Java interpreter. `Process` defines a platform-independent interface to platform-dependent processes running externally to the Java interpreter.

`Throwable` is the root class of the exception and error hierarchy. `Throwable` objects are used with the Java `throw` and `catch` statements. `java.lang` defines quite a few subclasses of `Throwable`. `Exception` and `Error` are the superclasses of all exceptions and errors. Figure 25.2 and Figure 25.3 show the class hierarchies for these core Java exceptions and errors.

#### Figure 25.2: The exception classes in the java.lang package

#### Figure 25.3: The error classes in the java.lang package

## 25.1 java.lang.AbstractMethodError (JDK 1.0)

###

Signals an attempt to invoke an abstract method.

    public class AbstractMethodError extends IncompatibleClassChangeError {
        // Public Constructors
                public AbstractMethodError();
                public AbstractMethodError(String s);
    }

### Hierarchy:

Object->Throwable(Serializable)->Error->LinkageError->IncompatibleClassChangeError->AbstractMethodError

java.io.Writer (JDK 1.1) |  | java.lang.ArithmeticException (JDK 1.0)