Can we know the count of the iteration (that is whether it's the first, second, third ... iteration ) while we are stepping over the code in a for each loop, in the eclipse debugger? Eclipse must be holding a count but how to get it show it to us. Apart from the workarounds of introducing an index in the code can we utilize something in built in eclipse.
Asked
Active
Viewed 950 times
0
-
1Why do you think eclipse holds a counter? – Mureinik Dec 01 '17 at 14:01
-
To iterate over all the values in a list, it must be keeping track of the list and its size.... – John Doe Dec 01 '17 at 14:02
-
1@JohnDoe why would it need a counter to do that? It can simply check if there is a next element and then get that next element just like iterators work. No counter required for iteration at all. – OH GOD SPIDERS Dec 01 '17 at 14:05
-
Hmmm, so we can not get the number of the iteration we are currently in, in case of a for loop. – John Doe Dec 01 '17 at 14:08
-
1Quite frankly: I don't know. Maybe eclipse does have an inbuilt counter for debugging iterations and maybe not. I was simply adressing the point that the idea that it must have one or otherwise iteration wouldn't work isn't really correct. – OH GOD SPIDERS Dec 01 '17 at 14:11
-
I meant to say that we can not get to know the number of the iteration in case of the for each loop. – John Doe Dec 01 '17 at 14:18
1 Answers
2
You can initiate a counter and increment it in the for loop, it should be a workaround.

Eugene
- 10,627
- 5
- 49
- 67
-
Apart from the workaround, is there in built thing which we can exploit. – John Doe Dec 01 '17 at 14:02
-
1