Processing question: sensors.length

I've been studying up on Processing and am confused by the following bit of code as it applies to reading multiple sensor values from the arduino. The code was copied from a tutorial here:
http://itp.nyu.edu/physcomp/Labs/SerialDuplex

// split the string at the commas
// and convert the sections into integers:
int sensors[] = int(split(myString, ','));

// print out the values you got:
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
}
// add a linefeed after all the sensor values are printed:
println();

I understand the entire sketch except the bolded parts. I think it creates an array where each of the separate sensor values is stored but not sure?

and then I'm lost on where the 'sensors.length' value comes from? Is that simply a function that is used to obtain the maximum value of what is stored in the 'sensors' array?

FWIW, I'm a newb (at about 3 days) with my Arduino and only 1 day into Processing...I'm not a programmer by trade ...have had my self on a crash course for about the last 72 hours and making good progress.

This line:

int sensors[] = int(split(myString, ','));

takes a string of comma seperated values (as ascii text) and splits the string into the different parts at the commas, and at the same time (with the int cast operator ) turns each ascii text number into an integer.

Finally these integers end up in the integer array "sensors"

this is a clever and very efficient way to take a string send from for instance Arduino and turn the string into a number of integers.

This line:

for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {

just loops throug all the integer values in the array returned by the line just mentioned before. sensors.length is just the way to get the number of elements (integers in this case) in the array.

I think that mayb it actually should have been :

for (int sensorNum = 0; sensorNum < sensors.length -1; sensorNum++) {

because the array is zero based, so if there are 15 elements in the array, the firs is 0 and the last is 14, but i might be wrong here.

If myString looks like this:

23, 45, 76, 19, -34

the split function will create an array of strings. Each string will contain one value (23 in the first string, 45 in the second string, etc.

The int function takes an array of strings and returns an array of integers created from those strings, if the strings represent integers.

Arrays are collections of objects. The collections have properties. One of the properties is lebgth, which contains the number of items in the collection.

Thank you both very much! Makes perfect sense. I haven't programmed since the 80's when I was a student...alas with no training in C! But programming is something I truly love to do and feel like I'm picking it up pretty quick!

I think the value in the loop is correct Mik. In it's final iteration of being true, the variable will increase to the maximum value and go through it's cycle of functions and correctly ending when the For condition is no longer met.

Yes you are right is says :

sensorNum < sensors.length

i would have been right, only if it had been:

sensorNum =< sensors.length