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 Arrays

Bhanu Awasthi
Bhanu Awasthi
1,780 Points

What does this mean - "i<jacksons.length" ?

String[] jacksons = {"Michael", "Jackie", "Tito", "Jermaine", "Marlon", "Randy"};

console.printf("The Jackson 5 are: %n");
for (int i = 0; i < jacksons.length; i++) {
  String jackson = jacksons[i];
  console.printf("%s Jackson %n", jackson);
}

} }

1 Answer

The second part of the for loop is the test condition. Each time the loop iterates it checks agains it to see if it should run again. In this loop it is saying Loop through the items while the variable i is less than the length of the array ( the number of the items in the array).

Here is a nice flowchart and further explanation:

http://www.tutorialspoint.com/javascript/javascript_for_loop.htm