Java. The java.lang package. General information

The java.lang package. General information. Overview of classes and interfaces


Search other resources:

1. The java.lang package. General information

The java.lang package is the main package used to develop Java programs. The package contains the most widely used interfaces and classes, without which it is impossible to write a program in Java.

This package is automatically imported into all programs. Therefore, in order to access the tools of a package, it is not necessary to include this package in the program using the line

import java.lang.*;

The package includes tools for expanding the capabilities of primitive data types, constituent elements of the language, working with strings, streams, and more.


2. The java.lang package classes

The java.lang package contains the following classes:

  • Boolean – wrapper class (wrapper class) for the boolean type;
  • Byte – a wrapper class for the byte type;
  • Character – a wrapper class for the char type;
  • Character.Subset – defines specific character sets of the Unicode set;
  • Class – encapsulates the runtime state of a class or interface;
  • ClassLoader – defines an object that is responsible for the order of loading classes;
  • ClassValue – used to associate a value with a type;
  • Compiler – provides the creation of environments in which the bytecode is compiled into the executive code;
  • Double – a wrapper class for the double type;
  • Enum – a class that serves as a superclass for all enumerations in the program;
  • Float – a wrapper class for the float type;
  • InheritableThreadLocal – designed to create local variables of threads of execution that can be inherited;
  • Integer – wrapper class for int type;
  • Long – a wrapper class for the long type;
  • Math – contains functions and constants for performing mathematical calculations on numeric types;
  • Number is an abstract superclass for the classes Byte, Short, Integer, Long, Float, Double;
  • Object – the superclass for all Java classes;
  • Package – contains information about the package version;
  • Process – a class that encapsulates a process. The process is the executable program;
  • ProcessBuilder – provides one of the ways to start processes (programs) and manage them;
  • ProcessBuilder.Redirect – encapsulates the source or destination of the I/O that is associated with the process;
  • Runtime – encapsulates the runtime environment;
  • RuntimePermission – provides a security mechanism in Java;
  • SecurityManager – provides a subclass inheritance mechanism for creating a security manager;
  • Short – a wrapper class over the short type;
  • StackTraceElement – is intended to describe an individual element of the stack trace;
  • StrictMath – provides a set of methods for performing mathematical calculations with increased accuracy;
  • String – a class containing tools for working with immutable character strings;
  • StringBuffer – defines a mutable string (as opposed to String);
  • StringBuilder – defines a mutable string. Objects of type StringBuilder are not safe for use in many threads, in which case it is better to use StringBuffer;
  • System – defines a set of useful static methods and variables;
  • Thread – designed to create a new thread of execution;
  • ThreadGroup – used to create a group of threads of execution;
  • ThreadLocal – used to create local variables for threads of execution;
  • Throwable – a class that is a superclass for all exception classes;
  • Void – contains a field that stores a reference to an object of the Class type for the void type.


3. The interfaces of java.lang package

The java.lang package defines a number of basic interfaces:

  • Appendable – designed to implement methods for adding characters or character sequences to objects;
  • AutoCloseable – provides support for the try statement with resources (automatic resource management);
  • CharSequence – defines methods that give read-only access to character sequences;
  • Cloneable – used in classes where you need to perform bitwise copying of objects (cloning);
  • Comparable – provides comparison of objects of classes according to some criterion. Used in methods of sorting (ordering) objects;
  • Iterable – for a set of objects, provides a for loop implementation in the for each style;
  • Readable – provides the use of an object as a source for reading characters;
  • Runnable – used for implementation in the class of the thread of execution;
  • Thread.UncaughtExceptionHandler – implemented by classes that need to handle unhandled exceptions.


Related topics