Results 1 to 4 of 4
Thread: Looping issue
- 07-11-2011, 04:46 AM #1
Looping issue
I am very aware of how loops should behave. If I have:
I get:Java Code:for(int i=0; i<4; i++){ System.out.println("*"); }
*
*
*
*
Simple enough...
However, I am seeing weird behavior in my code:
I get this outputJava Code:System.out.println("should loop "+data.length+" times"); for (int j = 0; j < data.length; i++) { System.out.println(i+" of "+data.length); data[i] = Integer.parseInt(temp[i]); System.out.println("adding a number"); }
Why is it going to the 5th iteration? Maybe I'm overlooking something simple.Java Code:should loop 4 times 0 of 4 adding a number 1 of 4 adding a number 2 of 4 adding a number 3 of 4 adding a number 4 of 4 ErrorEncountered: 4
Last edited by Fubarable; 07-11-2011 at 04:50 AM. Reason: quote tags changed to code tags
- 07-11-2011, 04:48 AM #2
amazing how reading through your own post helps...figured it out.
-
Yeah, i and j thing.
Also note that I changed your quote tags into code tags in your second block of code, to help make it more readable.
- 07-11-2011, 06:05 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
Similar Threads
-
help with program!! looping issue?
By zombian in forum New To JavaReplies: 6Last Post: 11-21-2010, 10:14 PM -
Looping
By Dean29126 in forum New To JavaReplies: 3Last Post: 09-08-2010, 02:01 PM -
Help with While and For Looping
By gmoney8316 in forum New To JavaReplies: 2Last Post: 03-03-2010, 10:54 PM -
Looping Help Please
By JonnySnip3r in forum New To JavaReplies: 5Last Post: 01-31-2010, 05:57 AM -
Class Scanner looping issue
By Stev0 in forum New To JavaReplies: 1Last Post: 05-25-2008, 06:53 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks