Hello I have a ArrayList<String> with some strings. I would like to insert a string at a specific index, without loosing the string on that index. I know how to use list.add(index, string) but it replaces the string at the index with the new one.
For example I have this ArrayList:
index 0 => Orange
index 1 => Melon
index 2 => Apple
index 3 => Strawberry
index 4 => Pear
index 5 => Banana
Now I would like to add Cherry to index 2, so the result should be:
index 0 => Orange
index 1 => Melon
index 2 => Cherry
index 3 => Apple
index 4 => Strawberry
index 5 => Pear
index 6 => Banana
Is there an easy way to do this, because it gives me headache.
Reference: ArrayList.add(index, element)
Should work on android too…