Java Java Data Structures Getting There Packages

So this get this clear, you use packages basically when you want to use another class you made in a different folder?

And this is only when the class you want to access is in a different folder? If its in the same folder you wouldn't have to do this correct?

1 Answer

Tonnie Fanadez
Tonnie Fanadez
UX Design Techdegree Graduate 21,842 Points

Hi Carolina Estrada

We use packages to group related classes together.

Let's say you love to listen to R&B and Hip-Hop songs. You can create 2 separate folders to organize the songs instead of mixing them - one folder to group R&B songs together and another folder for Hip-Hop songs only.

When classes are inside the same package you can access these classes without importing. However, if the class is in a different package, to use this class you need to import it using an import statement.

Again packages are used to group related classes together