demo1 java.util.Arrays.sort() 实现排序
class ArrayUtil {
public static void printArray(int temp []){
for(int x = 0;x < temp.length;x++){
System.out.print(temp[x] + ",");
}
}
}
public class HelloWorld {
public static void main(String[] args){
int data [] = new int [] {13,2,133,43,25,46};
ArrayUtil arrayUtil = new ArrayUtil();
java.util.Arrays.sort(data);// 排序,java自带排序方法
arrayUtil.printArray(data);
}
}
demo2 System.arraycopy , 数组A 选择部分内容,拷贝到数组B
class ArrayUtil {
public static void printArray(int temp []){
for(int x = 0;x < temp.length;x++){
System.out.print(temp[x] + ",");
}
}
}
public class HelloWorld {
public static void main(String[] args){
int dataA[] = new int[] {1,2,3,4,5,6,7,8,9};
int dataB[] = new int[] {11,22,33,44,55,66,77,88,99};
System.arraycopy(dataA,5,dataB,3,3);// 系统自带数组拷贝;
ArrayUtil arrayUtil = new ArrayUtil();
arrayUtil.printArray(dataB);//11,22,33,6,7,8,77,88,99,
}
}
标签:类库,ArrayUtil,printArray,temp,int,数组,new,public,6.8
From: https://www.cnblogs.com/pansidong/p/17456705.html