
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Packages in Java
Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier, etc.
A Package can be defined as a grouping of related types (classes, interfaces, enumerations, and annotations ) providing access protection and namespace management.
Some of the existing packages in Java are −
- java.lang − bundles the fundamental classes
- java.io − classes for input, output functions are bundled in this package
Programmers can define their own packages to bundle a group of classes/interfaces, etc. It is a good practice to group related classes implemented by you so that a programmer can easily determine that the classes, interfaces, enumerations, and annotations are related.
Since the package creates a new namespace there won't be any name conflicts with names in other packages. Using packages, it is easier to provide access control and it is also easier to locate the related classes.
- Related Articles
- Explain packages in Java
- What are packages in Java?
- Types of packages in Java
- Advantages of using packages in Java
- How to compile packages in Java
- Creating and using packages in Java
- Which packages contain Wrapper class in Java?
- Explain naming conventions for packages in java?
- Difference Between Packages and Interfaces in Java
- Difference between namespace in C# and packages in Java
- Packages in Python
- Packages in C#
- How many packages and classes are there in Java Standard Edition 8?
- Overview of Packages in Oracle
- What are Packages in Perl?
