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 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