java.lang Package
java.lang Package
In this tutorial, you will learn about java.lang Package. A Java package is a collection of related classes, interfaces, sub-packages, and other object-oriented types that are grouped together.
The java.lang Java package is the default package. It is automatically imported into every Java program, so you don’t need to explicitly import it. It provides classes that are fundamental and basic to the design of the Java Programming Language such as String, Math, class wrappers for primitive types and runtime support for threads. There is no need to import this package explicitly into the Java program.
-
It contains classes that are essential to Java programming.
-
Includes classes for:
-
Primitive type wrappers
-
Strings and string manipulation
-
Object reflection and class loading
-
Exception handling
-
Multithreading
-
System utilities
-
Interfaces
Some interfaces in the package are as follows:
- Cloneable
- Runnable
- Readable
- Appendable
Classes
Some other classes that are provided in the package are as follows:
Object class is the root of the Java class hierarchy. Every class has Object as the superclass. All objects in Java, implement the methods of this class.
Class instances of this class represent the classes at run time during Java program execution.
Class wrappers for primitive data types like:
- Boolean
- Byte
- Character
- Integer
- Float
- Long
- Double
Useful classes like:
- Object
- Class
- ClassLoader
- Runtime
- SecurityManager
- Math
- String
- StringBuffer
- StringBuilder
- System
- Thread
- ThreadGroup
- Process
- Void
- Error
- Exception
- Package
- Module, etc
Classes ClassLoader, Process, Runtime, SecurityManager, and System provide system operations. These classes manage the dynamic loading of Java Classes, the Creation of external processes, the enforcement of security policies, etc.
Class Throwable is the superclass of all errors and exceptions in Java programs. JVM can only throw objects of the Throwable class.
Note that: The Java language specification also provides a class called java.lang.Package which provides version information about the implementation of a Java package.
Sub Packages
Some of the sub-packages of java.lang Package is as follows:
- annotation
- invoke
- constant
- module
- management
- ref
- reflect
- runtime, etc
Java Tutorials
Java Tutorial on this website: