Write a statement that will remove the first element of the ArrayList names and store it in String firstName.
So this problem seems very simple and straight forward, this is answer I came up with:
String firstName = names[0];
names.remove(0);
But my teacher said it was wrong and that the answer is:
firstName = names.remove(0);
I agree that the second code is correct, but I am still convinced that my code is also correct. Can someone explain to me why it is wrong?
ArrayList!= array.