• Post Reply Bookmark Topic Watch Topic
  • New Topic

please explain this method to me  RSS feed

 
john hog
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

edit: i think i got it, i think i was confused on what the second for loop was doing but it just seems to be moving over each item by one because you are removing the very first item.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
john hog wrote:it just seems to be moving over each item by one because you are removing the very first item.


Yeah, that's pretty close. Just a couple of minor complaints:

1. No items are actually being "removed" from anything. What's happening in the inner loop is that it doesn't start at the beginning of the array.

2. You've noticed that the inner loop doesn't start at the beginning of the array, despite my first complaint. It does indeed skip over the first items. But not just the "very first item" -- have a look at the starting point of the inner loop again to see what it actually skips over.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!