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

Gendarme Docena
Gendarme Docena
1,509 Points

For (int I = 0; I < jacksons.length, i++)

Hi, can someone just explain this in english for me please?

For (int i = 0; i < jacksons.length, i++)

The way I'm saying it is like: I will start at 0, while i is less than the number of the jackson array, i will increment/increase it by one.

If that's correct, what is being increased/incremented by one?

3 Answers

Gendarme Docena
Gendarme Docena
1,509 Points

Oh yes! I meant to type in ";" not ","

I think this makes sense. So to say this statement in my head, it's like: "i equals 0, while i is less than the number of the jackson array length (which is 6), increase it by one."

Sorry, when I read code, I try to say it like an english statement. It seems to help.

Raphaël Seguin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Raphaël Seguin
Full Stack JavaScript Techdegree Graduate 29,228 Points

Hi, first the variable name should be the same everywhere, let's take "i", don't mix lower and upper cases, it won't work. Like this ('for' should be written in lower case, too) :

for (int i = 0 ; i < jacksons.length ; i++) { /* a statement */}

"I will start at 0, while i is less than the number of the jackson array, i will increment/increase it by one."

Your almost good, but i is compared to the LENGTH of the jacksons array.

To answer your question :) : it's the value contained in the variable i that is increased by one.

Does it help you ?

Raphaël Seguin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Raphaël Seguin
Full Stack JavaScript Techdegree Graduate 29,228 Points

...also you have to use ";" as separators, not ", " Like this : for ( initialise your variable ; compare it to something ; increase/decrease it )

Btw usage of variable name 'i' for variable in for loop is not for index, its for iterator. When you want to go through all elements of array you 'iterate' over array so i==iterator