In this post am going to explain how to add new item to a list at specific position.
You can add items to a list using myList.add("some thing"). but this adds that item as the last item in that list.
If you want to add a item at a specific position or if you want to insert a item into a list you can do it like below,
Ex: myList.insert(2, item) --> i am inserting this item at position 2.
You can add items to a list using myList.add("some thing"). but this adds that item as the last item in that list.
If you want to add a item at a specific position or if you want to insert a item into a list you can do it like below,
myList.insert(position, item);
Ex: myList.insert(2, item) --> i am inserting this item at position 2.