Java Standard Library Overview
The Java Standard Library (also called the Java API or JDK class library) is the large collection of ready-made classes and interfaces that ship with every Java installation. Instead of writing your own code to store lists of data, read files, or work with dates, you can reuse classes that Java’s creators already wrote, tested, and optimized.
Why It Matters
Every Java program you have written so far already uses the standard library. System.out.println, String, and Scanner are all standard library classes. Learning to recognize the major packages helps you find the right tool instead of reinventing one.
How the Library Is Organized
The library is split into packages — folders of related classes. A package name like java.util tells you the classes inside deal with utility data structures. You bring a package’s classes into your file with an import statement placed above the class definition.
Key Packages at a Glance
| Package | Purpose | Example classes |
|---|---|---|
java.lang |
Core language types, always available without an import | String, Math, Integer, Object |
java.util |
Collections, dates, random numbers, utilities | ArrayList, HashMap, Scanner |
java.io |
Reading and writing files and streams | File, BufferedReader |
java.time |
Modern dates, times, and durations | LocalDate, LocalTime |
java.math |
Precise numeric types beyond int and double |
BigInteger, BigDecimal |
java.net |
Networking and URLs | URL, Socket |
Using a Package: the import Statement
Classes in java.lang, such as String and Math, are available automatically in every file. Classes from any other package must be imported first, using the package name followed by the class name:
import java.util.ArrayList;
You place import statements at the very top of your file, before the class declaration.
Example: Combining Several Packages
This program uses three different parts of the standard library: a list from java.util, a math function from java.lang (no import needed), and a date from java.time.
import java.util.ArrayList;
import java.util.List;
import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
List<String> languages = new ArrayList<>();
languages.add("Java");
languages.add("Python");
languages.add("Go");
System.out.println("Languages: " + languages);
System.out.println("Count: " + languages.size());
double squareRoot = Math.sqrt(144);
System.out.println("Square root of 144: " + squareRoot);
LocalDate today = LocalDate.of(2026, 7, 18);
System.out.println("Sample date: " + today);
}
}
Output:
Languages: [Java, Python, Go]
Count: 3
Square root of 144: 12.0
Sample date: 2026-07-18
How It Works
List<String>andArrayListcome fromjava.utiland store a growable collection of strings.Math.sqrtcomes fromjava.lang, so it works without any import.LocalDate.ofcomes fromjava.timeand builds a calendar date from year, month, and day values.
Takeaway
The Java Standard Library is not one thing to memorize — it is a set of packages you gradually get familiar with as you need them. When you need a new kind of data structure, date, or file operation, check java.util, java.time, or java.io before writing it yourself. The next lesson looks more closely at working with dates and times using java.time.
