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 Basics Getting Started with Java Receiving Input

Pedro Araya
Pedro Araya
1,912 Points

What is a package in Java?

What is a package in Java?

1 Answer

Behold, the google hath spoken!

"A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer. You might keep HTML pages in one folder, images in another, and scripts or applications in yet another. Because software written in the Java programming language can be composed of hundreds or thousands of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages."

https://docs.oracle.com/javase/tutorial/java/concepts/package.html

So, think of a package like a group of related java files that are used to perform some kind of function. They are all related, and may interplay often, and so, since they are naturally related, it makes sense to group them together, say, in a package.