차근차근/JAVA JSP
구문자로 되어있는 문자열을 List로 넣는 방법
예쁜꽃이피었으면
2014. 11. 10. 14:28
http://jnylove.tistory.com/358
1. 문자열을 배열로 만든 후 for문을 이용해서 List에 add하는 방법
String str = " 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ";
ArrayList<String> list = new ArrayList<String>();
String[] toColumnNm = str.split(",");
for(int i=0; i<toCoumnNm.Lenfth;i++){
list.add(toColumnNm[i]);
}
2. Arrays.asList()를 이용하는 방법
String str = "1,2,3,4,5,6,7,8,9,10";
List<String> object = Arrays.asList(str.split(",");
반응형