DEV Community

VIDHYA VARSHINI
VIDHYA VARSHINI

Posted on

Package in Java

What is package: A package is used to group related classes. It is like a folder in a file directory. These are used to avoid name conflicts and to write a better maintainable code. It is divided into two categories :
a) Built-in package
b) User-defined package

Built-in package: The Java API is a library of pre-written classes, that are free to use, included in the Java Development Environment.
Some of the commonly used built-in packages are:
a) java.lang
b) java.io
c) java.util

User-defined package: These are the packages which are defined by the user. It helps us organize our own classes properly. We need to use user-defined packages because
a) To organize large projects
b) To avoid class name conflicts
c) To improve code readability
d) To control access using access modifiers

Top comments (0)