This package is so fundamental for all the Java class libraries that it is not only not required to be listed in the Maven configuration pom.xml file as a dependency (all other packages of the Java standard library are not required to be listed as a dependency too), but its members are even not required to be imported in order to use them. Any member of any package, whether standard are not, has to be imported or used with its fully qualified name, except classes and interfaces of the java.lang package. The reason for that is that it contains the two most important and the most used classes of Java:
- Object: The base class of any other Java class (see Chapter 2, Java Language Basics)
- Class: Its instances carry metadata of every loaded class at runtime (see Chapter 11, JVM Processes and Garbage Collection)
In addition, the java.lang package includes:
- The classes String, StringBuffer, and StringBuilders, which support operations with type String (see Chapter 15, Manage Objects, Strings, Time, and Random Numbers for more details and examples of usage)
- The wrapper classes of all primitive types: Byte, Boolean, Short, Character, Integer, Long, Float, and Double (see Chapter 9, Operators, Expressions, and Statements for more details about wrapper classes and their usage)
- The Number class, the base class for the numeral wrapper classes listed previously
- The System class, which provides access to important system operations and the standard input and output (we have used the System.out object in every code example in this book)
- The Runtime class, which provides access to the execution environment
- The Thread class and the Runnable interface, fundamental for creating Java threads
- The Iterable interface used by the iteration statements (see Chapter 9, Operators, Expressions, and Statements)
- The Math class, which provides methods for basic numeric operations
- The Throwable class – the base class for all exceptions
- The exception class Error and all its children, used to communicate system errors that should not be caught by an application
- The Exception class and its many children, which represent checked exceptions (see Chapter 10, Control Flow Statements)
- The RuntimeException class and its many children, which represent unchecked exceptions, also called runtime exceptions (see Chapter 10, Control Flow Statements)
- The ClassLoader class, which allows loading classes and can be used to build customized classloaders
- The Process and ProcessBuilder classes, which allow creating external processes
- Many other useful classes and interfaces