JAVA数组合并经典代码
由于JAVA中数组长度是不可变的,要想合并两个不同的数组,不能通过在一个数组的基础上追加另一个数组实现,需要创建一个新的数组,新数组长度是两个数组长度之和。然后将两个数组的内容导入到新数组中。具体实现代码:public class hello { public static void main(String[] args) { //两个待合并数组 int array1 [] = {20,10,30,50,40}; int array2 []
原创
2020-10-21 09:41:59 ·
454 阅读 ·
0 评论