Java contains thousands of built-in classes (around 4,500+), organized into different packages.
we mainly use classes from java.lang, java.util, java.io, java.time, java.sql, and java.net packages.
java.lang (Auto-imported – MOST IMPORTANT):
Class-----> Use
Object-> Parent of all classes
StringText-> handling
StringBuilder-> Mutable strings
StringBuffer-> Thread-safe strings
System-> I/O, GC
Math-> Math operations
Thread-> Multithreading
Exception-> Error handling
Runtime-> JVM interaction
java.lang is imported by default.
java.util (Collections & Utilities)
Class-----> Use
ArrayList-> Dynamic array
LinkedList-> Linked list
HashMap-> Key-value storage
HashSet-> Unique elements
Scanner-> Input
Collections-> Utility methods
Date-> Date (legacy)
Optional-> Avoid null
java.io (File & Stream Handling)
Class----> Use
File-> File handling
FileInputStream-> Read binary data
FileOutputStream-> Write binary data
BufferedReader-> Read text
InputStreamReader-> Stream → Reader
java.time (Modern Date & Time – Java 8+)
Class-----> Use
LocalDate-> Date
LocalTime-> Time
LocalDateTime-> Date + Time
Period-> Date difference
Duration-> Time difference
java.sql (Database – JDBC)
Class-----> Use
Connection-> DB connection
Statement-> SQL execution
PreparedStatement> Secure SQL
ResultSet> Query result
java.net (Networking)
Class-----> Use
URL-> Web address
Socket-> Client connection
ServerSocket-> Server connection
Top comments (0)