Witscale Test Center

13.1 The java.lang package


13.1 The java.lang package

The java.lang package contains the fundamental classes of the Java language.  For this reason, all classes in the java.lang package are imported automatically in a Java code. Therefore, you need not write an import statement while using them in your code. There are many classes in java.lang, but we will see only the prominent ones (from the exam point of view).

The Object class is one of the most fundamental classes of Java. All Java classes inherit from this class. In other words, this class is the granddaddy of all classes. Besides Object, the package java.lang also defines the String, StringBuffer classes representing a sequence of characters and the wrapper classes for all primitive types (and also for the void type). The wrapper classes have similar name to the type they are wrapping. They are Boolean, Byte, Short, Character, Integer, Long, Float, Double and Void.


Besides wrappers, the java.lang package also contains a utility class called Math class. This class defines several utility methods and constants that can be used to perform basic mathematical operations. Figure 13.1 gives a quick overview of these classes in java.lang package.

 

 

Figure 13.1 Some of the important classes including the wrapper classes in java.lang package

 

Besides the classes shown in figure 13.1, the java.lang package also contains other important classes such as Thread class and interfaces Runnable, Serializable etc. Since we have already studied some of them, we will be learning about the classes which we haven’t seen so far. Let us start with the Math class first.