Originally posted by tyler jones:
Thanks a lot. Could you explain a bit of the looping logic? That is where I'm having trouble understanding it. Thanks again.
We have entered two names on the command line. When the names are read in they will populate the first two "storage buckets" of the array. In Java they are numbered 0, 1, 2, etc.
In the for loop, the loop will continue to loop until it is equal to what you set it at. In this case, it is less than args.length.
The first time the loop iterates i is equal to 0. The first if says that if (i is equal to args.length -2), this would be 2 - 2 = 0. So, I does equal 0, so it will make String f = the value of
args[i] and at this point, i = 0, so it will put String f = the value of the first "storage bucket" in the array, which is args[0].
Then it will check the other if statements.
Then it will loop or iterate and the value of i will be increased by 1 because you have i++ as the incrementor of your for loop. So now i is equal to 1.
So now it will check the if statements based on i being 1
Then it will iterate again this time i will become 2.
Now, since i is now eqial to two, and you said it should iterate while i < args.length (which is 2), it will no longer iterate.
So, for (i = 0(this is the beginning value of i); i < args.length( this is where you tell it to iter until this condition exists); i++(this is what increments the value of i).
I hope all ths babble has helped.
Good Luck!