當前位置:首頁 » 編程語言 » 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-09-18 05:38:49 瀏覽:958
使用jsp腳本輸出九九乘法表 發布:2025-09-18 05:22:11 瀏覽:663
出行解壓 發布:2025-09-18 05:20:54 瀏覽:574
安卓手機畫線怎麼用 發布:2025-09-18 05:16:43 瀏覽:697
解壓吃蔬菜 發布:2025-09-18 05:10:04 瀏覽:818
php判斷數組個數 發布:2025-09-18 04:54:02 瀏覽:664
linuxmd5c 發布:2025-09-18 04:47:04 瀏覽:345
數據結構編譯器哪個好 發布:2025-09-18 04:33:52 瀏覽:437
ad轉換c語言 發布:2025-09-18 04:21:21 瀏覽:755
sqlserver2008設置外鍵 發布:2025-09-18 04:21:12 瀏覽:117