Could anyone please explain me why this code snippet works?
Object[] op = new Object[0];
ArrayList r = new ArrayList();
r.add("1");
r.add("3");
r.add("5");
r.add("6");
r.add("8");
r.add("10");
op = r.toArray();
System.out.println(op[3]);
This prints out 6. I know that you can convert list to array but I was thinking that if the array is fixed size then you can't add further elements. In this case the array op is with fixed size "0" so why/how are the list elements being added to the array? Thanks