Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 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