開發時,有時候會需要將Array轉成ArrayList,透過Arrays的asList的方法就可以做到

import java.util.List;
import java.util.Arrays;
public class test {
    public static void main(String [] argv) {
		Integer [] ch_arr = {26,21,6,13,16,11,12,15,4,1,3,19,9,23,8,7,22,18,17,10,25,2,24,5,14,20};
		//透過asList轉換成ArrayList
		List<Integer> list = Arrays.asList(ch_arr);
    }
}
Categories: Java