Suppose I have a lot of String Variables(100 for example):
String str1 = \"abc\";
String str2 = \"123\";
String str3 = \"aaa\";
....
String st
The following creates the ArrayList
on the specific String
values you have:
ArrayList list1 = new ArrayList() {{addAll(Arrays.asList(new String[]{"99", "bb", "zz"}));}};
Or, if it's just some distinct values you want, use this for say - 10 of them:
ArrayList list2 = new ArrayList() {{for (int i=0; i<10; i++) add(""+System.currentTimeMillis());}};