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

}
}

運行結果如下:

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:559
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:841
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:546
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:722
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:645
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:963
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:218
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:76
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:767
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:673