當前位置:首頁 » 編程語言 » java數組轉為list

java數組轉為list

發布時間: 2023-06-29 01:39:50

java中數組如何轉換成List

//小例子
//這里注意的是,不能是基本類型,必須是包裝類Byte[]可以。
publicclassDemo{
publicstaticvoidmain(String[]args)throwsException{
String[]arr={"asd","sd","df"};
Listlist=Arrays.asList(arr);
System.out.println(list);
}
}

⑵ 在Java中怎樣把數組轉換為ArrayList

方法一:

ArrayListlist=newArrayList(Arrays.asList(array));

方法二:

publicListgetList(Object[]obj)throwsException{
Listlist=newArrayList();
for(inti=0;i<obj.length;i++)
list.add(obj[i]);
returnlist;
}
熱點內容
達內培訓php多少錢 發布:2025-05-14 07:19:10 瀏覽:25
python位元組轉字元串 發布:2025-05-14 07:06:35 瀏覽:421
subplotpython 發布:2025-05-14 06:53:51 瀏覽:661
豎屏大屏導航工廠密碼一般是多少 發布:2025-05-14 06:49:29 瀏覽:806
如何在手機里設置無線網密碼 發布:2025-05-14 06:47:54 瀏覽:120
動態ip文件伺服器 發布:2025-05-14 06:44:22 瀏覽:891
文字分行的腳本有什麼 發布:2025-05-14 06:33:10 瀏覽:288
svn小烏龜怎麼配置 發布:2025-05-14 06:31:43 瀏覽:393
視頻播放器android 發布:2025-05-14 06:31:43 瀏覽:720
android工作室 發布:2025-05-14 06:26:00 瀏覽:658