Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Exploring the Java Collection Framework Sets

Eric Tang
Eric Tang
Courses Plus Student 1,300 Points

for(Treet treet: treets)

It's really hard and confusing to wrap my head around this line. I've seen instances of these sort of usage. I don't understand why the word "Treet" is infront of the variable Treet. If it was Strings I would get it but why Treet. Can someone run through what this line actually does. Is the line grabbing resource from the Treet class?

1 Answer

Vladut Astalos
Vladut Astalos
11,246 Points

Just like when you use String in front of a variable to declare an object of type String you use Treet in front of a variable to declare an object of type Treet. The only difference is that Treet is a custom class you created on your own while String is a built-in class.

thanks you