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 trialJimmy Chung
1,600 PointsWhy is importing a public class (Treet) necessary?
It is my understanding that public classes can be used outside of the package.
1 Answer
Alison Brodribb
24,615 PointsPublic classes can still be accessed outside of the package, but you still need to import the Treet class file into your main class so that the Treet class file becomes visible to your main package.
The java complier will only automatically compile files in the same package - for classes in other packages, you need to import each file.