© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
J. FriesenLearn Java Fundamentalshttps://doi.org/10.1007/979-8-8688-0351-2_10

10. Packages

Jeff Friesen1  
(1)
Dauphin, MB, Canada
 

Same-named reference types (e.g., two different Math classes) can cause name conflicts when you try to use them, but Java overcomes this problem with packages. This chapter introduces you to the package concept followed by the package and import statements. Finally, you learn about static imports, protected access, and JAR files.

What Are Packages?

Java developers group related classes and/or interfaces into packages, which are unique namespaces for storing reference types. Packages can store classes, interfaces, and subpackages

Get Learn Java Fundamentals: A Primer for Java Development and Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.