The console doesn’t keep track of every line ever printed. It’s only going to go back a few thousand lines. Usually there is no point in tracking more than that.
In any case, it should be obvious that the loop is processing every line of data in the file.
Now that you have the first two values from the file stored in variables, it is up to you to work out a way to use them. Since you want to make your Ball objects do something or look different depending on these values, it makes sense to pass these values into the constructor for your Ball class. In previous code you have posted, you have already done this sort of thing with the origin variable. You must understand this because it’s code you already had… so you either wrote it and already understand it (great), or you got some example code and then took the time to understand it, right?
You’re also going to need to reconcile the number of Ball objects you want. Previously, you had 100 of them. Are you now going to have one for each line in your CSV file (that is, 4000+ Balls)? Or are you going to stick with 100 of them?
In short, you need to make this loop:
for (int i = 0; i < 100; i++) {
Vec3D origin = new Vec3D (random(width), random(130), 0);
Ball myBall = new Ball(origin);
ballCollection.add(myBall);
}
and this loop:
for (int i = 0; i < data.length; i++) {
println("Now looking at line -> " + i + ", which is " + data[i]);
String [] splitNums = split(data[i], ',');
for (int j=0; j < splitNums.length; j++){
println("" + i + "," + j + " => " + splitNums[j]);
float a = float(splitNums[0]);
float b = float(splitNums[1]);
}
}
be the same loop!