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 - Retired Organizing Data Interfaces

A little explanation

Please I need a little explanation on this code written at the Example.java class: for (Treet exampleTreet : treets) { System.out.println(exampleTreet); }

Try watching the arrays series of videos for java.

1 Answer

Mark Casavantes
PLUS
Mark Casavantes
Courses Plus Student 13,401 Points

Good Morning Eugene,

Basically, there is more than one way to create a for loop. What is listed below is what you may be most familiar with.

for (initialization condition; testing condition; increment/decrement)
{
    statement(s)
}

There is also this way of creating a for loop which relates to the example you provided.

int [] numbers = {10, 20, 30, 40, 50};

for(int x : numbers ) 
{
         System.out.print( x );
         System.out.print(", ");
}

Mark