Introduction
The java.lang package is one of Java's most fundamentally used packages. It contains classes that practically design most of your code. The java.lang package provides classes for Mathematical operations, String operations, and System operations. It also provides Wrapper classes that wrap data into objects.
One can find the java.lang package in the lib directory under the Java Runtime Environment installed folder. Java.lang is imported by default into a Java program by the compiler as it contains a number of components that give functionality to a program.
Also see, Duck Number in Java and Hashcode Method in Java.
Interfaces
Example:
The below example shows the use of the Runnable and CharSequence interface from the java.lang package
class ThreadDemo implements Runnable
{
public void run()
{
System.out.println("Thread is running");
}
}
class StringSeq
{
public void stringSequence(CharSequence chs)
{
System.out.println(chs.subSequence(6,10));
}
}
public class Main
{
public static void main(String[] args)
{
StringSeq s = new StringSeq();
s.stringSequence("Let's play");
Thread object = new Thread(new ThreadDemo());
object.start();
}
}
Output:
Play
Thread is running