Menu

(Solved) : Int X 2 Arraylist Citylist New Arraylist Classlistadd Houston Classlistadd Vegas Classlist Q37178995 . . .

int x = 2

ArrayList<String> cityList = newArrayList<String>();
classList.add(“Houston”);
classList.add(“Vegas”);
classList.add(“LA”);
classList.add(“Atlanta”);
classList.add(“Miami”);

_________

With the ArrayList provided above, how do I remove objects fromthe ArrayList in terms of variable “x” starting at position “0”?

I do not want to do it using two different “.remove()” methods.I would like to do it using just one line of code or a forloop.

the output should be:

[LA, Atlanta, Miami]

Expert Answer


Answer to int x = 2 ArrayList cityList = new ArrayList(); classList.add(“Houston”); classList.add(“Vegas”); classList.add(“LA”); c…

OR