Java/자카르타 Apache-commons-lang ArrayUtils test 우혁이 아빠 2012. 7. 18. 17:04 // @Test public void test_006() throws Exception { List<String> list = new ArrayList<String>(); list.add("aaa"); list.add("bbb"); list.add("ccc"); list.add("ddd"); String [] array = new String[list.size()]; array = list.toArray(array); for (String str : array) { System.out.println(str); } // aaa // bbb // ccc // ddd } // @Test public void test_005() throws Exception { String[] array = ArrayUtils.toArray("aaa", "bbb", "ccc", "ddd"); String str = ArrayUtils.toString(array); System.out.println(str); // {aaa,bbb,ccc,ddd} } // @Test public void test_004() throws Exception { String [][] array = {{"1", "aaa"}, {"2", "bbb"}, {"3", "ccc"}, {"4", "ddd"}}; Map<Object, Object> map = ArrayUtils.toMap(array); Set<Object> keySet = map.keySet(); for (Object key : keySet) { System.out.println("key : " + (String) key + ", value : " + map.get((String) key)); } // key : 3, value : ccc // key : 2, value : bbb // key : 1, value : aaa // key : 4, value : ddd } // @Test public void test_003() throws Exception { String[] array = ArrayUtils.toArray("aaa", "bbb", "ccc", "ddd"); for (String str : array) { System.out.println(str); } // aaa // bbb // ccc // ddd } // @Test public void test_002() throws Exception { String [] strs = {"aaa", "bbb"}; boolean result = ArrayUtils.contains(strs, "aaa"); System.out.println(result); // true } // @Test public void test_001() throws Exception { String [] strs = {"aaa", "bbb"}; String[] strs2 = ArrayUtils.add(strs, "ccc"); for (String str : strs2) { System.out.println(str); } // aaa // bbb // ccc } 저작자표시 (새창열림)