當前位置:首頁 » 編程語言 » java撥鍾

java撥鍾

發布時間: 2024-07-16 21:16:09

java字元串數組合並 怎麼合並成一個數組

java字元串數組合並,可以使用array.復制方法,如下代碼:

packagecom.qiu.lin.he;

importjava.text.ParseException;
importjava.util.Arrays;

publicclassCeshi{
publicstaticvoidmain(String[]args)throwsParseException{

String[]str1={"J","a","v","a","中"};
String[]str2={"如","何","把","兩","個","數","組","合","並","為",
"一","個"};

intstrLen1=str1.length;//保存第一個數組長度
intstrLen2=str2.length;//保存第二個數組長度
str1=Arrays.Of(str1,strLen1+strLen2);//擴容
System.array(str2,0,str1,strLen1,strLen2);//將第二個數組與第一個數組合並
System.out.println(Arrays.toString(str1));//輸出數組

}
}

運行結果如下:

熱點內容
我與預演算法 發布:2025-07-13 11:20:28 瀏覽:426
線譜演算法 發布:2025-07-13 11:17:15 瀏覽:838
怎麼把文件上傳百度雲 發布:2025-07-13 11:09:18 瀏覽:556
光遇安卓玩家如何加蘋果玩家 發布:2025-07-13 11:08:21 瀏覽:477
安卓哪裡下載破解游戲 發布:2025-07-13 11:02:30 瀏覽:324
三菱如何查找未編譯的程序 發布:2025-07-13 11:02:29 瀏覽:389
2013全國計算機二級c語言真題 發布:2025-07-13 10:58:17 瀏覽:174
python讀取txt 發布:2025-07-13 10:56:50 瀏覽:641
c語言ftp伺服器 發布:2025-07-13 10:56:36 瀏覽:413
mdb壓縮 發布:2025-07-13 10:56:02 瀏覽:425