方式一:
ArrayList<String> list = new ArrayList<String>(); String str01 = String("str01"); String str02 = String("str02"); list.add(str01); list.add(str02);
方式二:
ArrayList<String> list = new ArrayList<String>(){{add("str01"); add("str02");}};
方式一:
ArrayList<String> list = new ArrayList<String>(); String str01 = String("str01"); String str02 = String("str02"); list.add(str01); list.add(str02);
方式二:
ArrayList<String> list = new ArrayList<String>(){{add("str01"); add("str02");}};
转载于:https://www.cnblogs.com/liaojie970/p/6907870.html