package test;
import java.util.Arrays;
public class test {
public static void main(String[] args) {
int a[] = new int[] { 10, 5, 3, 2, 6, 8, 7, 9, 1, 4 };
int b[] = Arrays.copyOfRange(a, 2, 6);// 截取索引2(包括)到索引6(不包括)的元素
System.out.println(Arrays.toString(b));
}
}
输出:
[3, 2, 6, 8]