Java
The following code was not exactly explained how the list[i] = list[i-1] *2 works. Can you give me a iteration step by step how the output is calculated. ie if the 1st iteration is 0 then how was it calculated? ie is it (1-1)*2?
public class TestTwo
{
public static void main(String[] args)
{
int[] list = {1,2,3,4,5,6};
for(int i = 1; i < list.length; i++)
{
list[i] = list[i – 1] * 2;
}
for(int i = 0; i < list.length; i++)
{
System.out.print(list[i] + ” “);
}
}
}
