As the name suggests a package in java that contains all the same kinds of classes, Abstract classes, interfaces, etc that have the same functionality. A Single package can contain many classes, Abstract classes e.g. java.util package etc.
There are two types of packages:
- Built-in-package: These are the packages that are predefined in the java jar file. The most commonly used package in java. util and java.io package in java.
- User-defined package: These packages are created by the user that used to store related classes some other utility functions, interfaces and abstract classes, etc which are defined for the specific task is called a user-defined package.
Project -- GFG | | Package 1 GFG1 | GFG1.java (class) Package 2 GFG2 | GFG2.java (class) | GFG3.java (class)
Accessing the members of package 1 class in package 2 class:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.