Maybe this is a stupid question, but i still wonder
if i use
ArrayList<Integer> Data=new ArrayList<Integer>();
for(int data:Data)
//some code here
//print out the iteration times
i want to print out the iteration times (not the execution time)
without using
for int i;i<blahblahblah;i++) output i
for example output
output:
This is iteration times: 1 the data is : blahblahblah
This is iteration times: 2 the data is : blahblahblah
This is iteration times: 3 the data is : blahblahblah
Well this may not be correct asthetically
since for each loop accesses the elements sequentially it will give you the iteration number = (index + 1)
Edit:
If you can remove the element you can ensure that the duplicates problem will not occur. Or else the traditional for loop is best suited