當前位置:首頁 » 編程語言 » 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));//輸出數組

}
}

運行結果如下:

熱點內容
python的sort函數 發布:2025-07-12 15:53:21 瀏覽:47
ensp伺服器怎麼設置web根目錄 發布:2025-07-12 15:47:56 瀏覽:283
安卓怎麼設置二卡發信息 發布:2025-07-12 15:43:50 瀏覽:742
如何看到無線密碼 發布:2025-07-12 15:43:13 瀏覽:674
好網址可緩存 發布:2025-07-12 15:36:07 瀏覽:251
centos安裝php52 發布:2025-07-12 15:14:19 瀏覽:297
usb介面編程 發布:2025-07-12 15:14:19 瀏覽:214
演算法學習心得 發布:2025-07-12 15:14:08 瀏覽:793
華為手機內核編譯 發布:2025-07-12 15:13:13 瀏覽:837
匯編語言編譯器masm 發布:2025-07-12 14:57:37 瀏覽:56