The Java language package, a.k.a. java.lang, provides classes that are core to the Java language. If you are writing stand-alone Java applications, you are likely to encounter and use the classes and interfaces in this package first. The classes in this package are grouped in the following manner:
- The grand-daddy of all classes--the class from which all others derive.
- Data Type Wrappers
- A collection of classes used to wrap variables of a simple data type: Boolean, Character, Double, Float, Integer and Long. Each of these classes are subclasses of the abstract class Number.
- Two classes that implement mutable and immutable character data. The String and StringBuffer Classes is a thorough lesson on the use of both types of strings.
- System and Runtime
- These two classes provide let your programs use system resources. System provides a system-independent programming interface to system resources and Runtime gives you direct system-specific access to the runtime environment. Using System Resources describes both the System and Runtime classes and their methods.
- The Thread, ThreadDeath and ThreadGroup classes implement the multi-threading capabilities so important to the Java language. The java.lang package also defines the Runnable interface. Runnable makes it convenient for Java class to be active without subclassing the Thread class. Through an example-oriented approach Threads of Control will teach you about Java threads.
- The Class class provides a runtime description of a class and the ClassLoader class allows you to load classes into your program during runtime.
- A library of math routines and values such as pi.
- Exceptions, Errors and Throwable
- When an error occurs in a Java program, the program throws an object which indicates what the problem was and the state of the interpreter when the error occurred. Only objects that derive from the Throwable class can be thrown. There are two main subclasses of Throwable: Exception and Error. Exceptions are a form of Throwable that "normal" programs may try to catch. Errors are used for more catastophic errors--normal programs should not catch errors. The java.lang package contains the Throwable, Exception and Error classes, and numerous subclasses of Exception and Error that represent specific problems.
- Process objects represent the system process that is created when you use Runtime to execute system commands. The java.lang packages defines and implements the generic Process class and two of its subclasses that represent processes on specific platforms: UNIXProcess and Win32Process.
The compiler automatically imports this package for you. No other packages are automatically imported.