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 Objects (Retired) Creating the MVP Prompting for Guesses

Hasan Nagaria
Hasan Nagaria
4,855 Points

Java classes link?

How are the different java classes linked? I mean I know that the methods are public, but like. When I learnt C++ I would have to include them in my headers etc. No such thing is required here?

1 Answer

Enrique Munguía
Enrique Munguía
14,311 Points

The basic unit to group classes in Java is called package. A package contains a set of related types (classes, enums, interfaces, etc), you can create your own packages or use the ones provided in the JDK. Suppose you want to include a class from another package you created, in your code write the line

import myPackage;

This allows your current code to recognize the types in myPackage.