I know this question is asked a lot of times in Stack Overflow but mine is a bit different.
I understand that ArrayList
begin at index 1 and Arrays
begin at index 0. Am I right?
If not then when I convert my ArrayList
to an Array.
Ex: code
List<String> list = new ArrayList<String>();
list.add("India");
list.add("Switzerland");
list.add("Italy");
list.add("France");
String [] countries = list.toArray(new String[list.size()]);
So if I my first comment was right (If it was. Because on the net I find 3/4 people saying array list begins at 0 at 1/4 saying array list begins at 1. I am a beginner so I have no idea, which is correct?
So if ArrayList
begin at 1.
So can the Ex: Code be converted to
List<String> list = new ArrayList<String>();
list.add("India");
list.add("Switzerland");
list.add("Italy");
list.add("France");
String [] countries = list.toArray(new String[list.size()-1]);
Pls. do let me know. Thanks!