Hey guys i am learning java and I would like to know what would excute when the following code runs baiscally the ouput of this code
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(2);
list.add(1);
list.add(0);
int n = list.size();
for (int i=0;i<n;i++)
{
int v=list.get(i);
if (v>0)
list.add(0,v);
}
}
}
Choices to consider
A) [2,1,0,1,2]
B) [2,1,0,2,1]
C) [2,1,2,1,0]
D [2,2,2,2,1,0]
Or no output ( Program goes into infinte loop
I hope you help me and also give me an explanation ..
thanks