Skip to main content

Command Palette

Search for a command to run...

JAVA-00-Built-in Packages

Published
6 min readView as Markdown

Below is a complete, structured explanation of the main built-in classes in Core Java, with what they do, where they belong, and simple examples 👇


🧩 1️⃣ java.langFundamental Classes (Auto Imported)

Contains classes that are automatically imported in every Java program.

ClassDescriptionExample
ObjectSuperclass of all Java classestoString(), equals(), hashCode()
StringImmutable sequence of characters"Hello".length()
StringBuilderMutable string (non-synchronized)new StringBuilder("Hi").append("!")
StringBufferMutable string (thread-safe)new StringBuffer("Hi").append("!")
MathMathematical functionsMath.sqrt(9) → 3
SystemAccess to system input/output and propertiesSystem.out.println()
ThreadFor creating and managing threadsnew Thread(runnable).start()
RunnableInterface for threadingpublic void run()
Throwable, Exception, ErrorBase classes for exception hierarchytry { ... } catch(Exception e)
Integer, Double, Float, Long, etc.Wrapper classes for primitivesInteger.parseInt("10")
EnumBase type for all enumerationsenum Color {RED, BLUE}
ClassRepresents class metadata at runtimeobj.getClass()
PackageRepresents a Java packagePackage p = obj.getClass().getPackage();

🧩 2️⃣ java.utilUtility and Collection Framework

Contains the Collection Framework, date/time, random number, and other helpers.

CategoryImportant ClassesDescription / Example
CollectionsArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap, Vector, StackStore and manipulate groups of objects
InterfacesCollection, List, Set, Map, Queue, Iterator, IterableDefine collection types and traversal
Date/Time (old)Date, Calendar, TimeZonenew Date()
UtilityRandom, Scanner, Objects, Optional, Collections (class with static methods)e.g., Collections.sort(list)
Properties & ResourceProperties, ResourceBundleStore configuration or localization data

🧩 3️⃣ java.ioInput / Output (File Handling)

Handles reading and writing data (files, streams).

ClassDescription / Example
FileRepresents a file or directory
FileReader / FileWriterRead/write character data
BufferedReader / BufferedWriterEfficient character I/O
FileInputStream / FileOutputStreamByte-level file handling
ObjectInputStream / ObjectOutputStreamFor serialization
PrintStreamEasy output (used by System.out)
InputStreamReader / OutputStreamWriterConvert between bytes and characters

🧩 4️⃣ java.nioNew I/O (Buffers & Channels)

More modern, faster I/O for files and networks.

ClassDescription
PathRepresents file/directory path
FilesUtility for file operations (Files.readAllLines())
ByteBuffer / CharBufferBuffers for data
FileChannelChannel-based file access
StandardOpenOptionOptions for opening files

🧩 5️⃣ java.timeModern Date and Time API (Java 8+)

More powerful and thread-safe date/time classes.

ClassDescription
LocalDate, LocalTime, LocalDateTimeRepresents date, time, and both
ZonedDateTimeDate/time with time zone
Period / DurationDifference between dates/times
DateTimeFormatterFormatting/parsing dates

🧩 6️⃣ java.mathHigh Precision Math

ClassDescription
BigIntegerInteger of any size (arbitrary precision)
BigDecimalDecimal numbers with high precision (financial calculations)

🧩 7️⃣ java.netNetworking

ClassDescription
URLUniform Resource Locator (web link)
URLConnectionConnection to a resource
Socket / ServerSocketClient/server socket programming
InetAddressRepresents IP address

🧩 8️⃣ java.sqlDatabase (JDBC)

Class / InterfaceDescription
DriverManagerManages JDBC drivers
ConnectionRepresents DB connection
StatementExecute SQL queries
PreparedStatementPrecompiled queries
ResultSetHolds query results
SQLExceptionHandles DB errors

🧩 9️⃣ java.util.concurrentMultithreading & Concurrency

ClassDescription
ExecutorServiceManages threads efficiently
Callable, FutureReturn results from threads
ReentrantLockAdvanced synchronization
CountDownLatch, Semaphore, CyclicBarrierThread coordination tools
ConcurrentHashMapThread-safe map

🧩 🔟 java.awt & javax.swingGUI (Graphical User Interface)

ClassDescription
Frame, Button, Label, TextFieldAWT basic UI components
JFrame, JButton, JLabel, JPanelSwing components
EventListenerHandles UI events

🧩 11️⃣ java.securitySecurity and Encryption

ClassDescription
MessageDigestUsed for hashing (like SHA-256)
KeyPair, SignatureCryptography utilities
SecureRandomGenerates secure random numbers

🧩 12️⃣ java.lang.reflectReflection API

ClassDescription
ClassRepresents class metadata
MethodRepresents a class method
FieldRepresents class fields
ConstructorRepresents constructors
ModifierAccess modifiers info

🧩 13️⃣ java.util.regexRegular Expressions

ClassDescription
PatternCompiles regex
MatcherMatches regex patterns
ExamplePattern.matches("[a-z]+", "abc")

🧩 14️⃣ java.util.streamStream API (Java 8+)

Class / InterfaceDescription
Stream<T>Represents sequence of elements
CollectorsUsed to collect results
IntStream, LongStream, DoubleStreamSpecialized streams
Examplelist.stream().filter(x -> x>10).forEach(System.out::println);

🧩 15️⃣ java.util.functionFunctional Interfaces (Lambda Support)

InterfaceDescription
Function<T,R>Takes one input, returns output
Predicate<T>Returns boolean result
Consumer<T>Consumes input, no return
Supplier<T>Returns a value, no input
ExamplePredicate<Integer> p = n -> n > 10;

⚡ Quick Summary Table

CategoryPackagePurpose
Core classesjava.langFundamental classes
Collectionsjava.utilData structures
File I/Ojava.ioRead/write data
Date/Timejava.timeModern time handling
Databasejava.sqlJDBC
Networkjava.netNetworking
Mathjava.mathPrecision math
Concurrencyjava.util.concurrentMultithreading
Regexjava.util.regexPattern matching
Streamsjava.util.streamFunctional data processing
Functionaljava.util.functionLambdas and functional interfaces
Reflectionjava.lang.reflectInspect classes at runtime
GUIjava.awt, javax.swingUser interface
Securityjava.securityEncryption, hashing

More from this blog

SS-JAVA

23 posts