Lookup map for converting Strings into Android `R.raw` integers
There is not such thing as ArrayMap in standard Java. Therefore, I am just going to assume that you meant HashMap.



I would choose neither of those options. Depending on how many elements you need to insert into that Map, you could end up with a big chunk of code that is just a group of add calls.

I recommend creating two arrays: one of the Strings, and one of the Integers.

Then, all you have to do is create a loop that inserts all the values into the map.

Here is what I came up with:

String[] foos = {...};
Integer[] bars = {...};
Map&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;();

for(int i = 0, length = foo.length; i &lt; length; i++) {
    map.put(foos[i], bars[i]);
}