글
ArrayList를 String[]으로 변환하기
JAVA
2014. 2. 12. 15:02
이게 되는구나 구지 힘들게 클래스를 이용하여 Gson을 이용하지 않아도 되겠다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | package pkg1; import java.util.ArrayList; import java.util.List; public class Mytest { public static String[] hello(){ List<String> mylist = new ArrayList<String>(); mylist.add("FUCK"); mylist.add("SUNOFBEACH"); return (String[])mylist.toArray(new String[mylist.size()]); } public static void main(String[] args) { String[] a = hello(); System.out.println(a[0]); System.out.println(a[1]); } } |