How to initialize a two column arraylist?
android, arraylist, java
Solution
I think you should use a `HashMap` with `int` as key and `String` as value if your `int` values are going to be unique.
Map<Integer,String> myMap = new HashMap<Integer,String>();
myMap.put(1,"ABC");
Note that as `Map` is a collections and java collections do not store primitive like `int`, they store objects so you have to use `Integer` wrapper class for your `int` values.
Refer this link Why can Java Collections not directly store Primitives types?
Problem
I need to create a List that records two columns {int, String}. I think ArrayList is what I need but I cant get my head around it. I pulled the Strings from a database and the int is the index value which I need to identify the strings position for later. `List<List<String>> strArray = ArrayList<List<String>>;` then could I do something like strArray.add().add() for each row I pull from the database?