java 数组拆分为新数组

1

[85, -86, 13, 2, 99, 99, 99, 99, 98, 98, 99, 99, 99, 99, 20, 85, -86, 13, 2, 99, 99, 99, 99, 99, 99, 99,85, 12, 85, -86, 13, 2, 99]

[85, -86, 13, 2, 99, 99, 99, 99, 98, 98, 99, 99, 99, 99, 20]

[85, -86, 13, 2, 99, 99, 99, 99, 99, 99, 99]

[85, 12]

[85, -86, 13, 2, 99]

myfc | 初学一级 | 园豆：114

1

public void ArrFun1() {
int[] arr = {85, -86, 13, 2, 99, 99, 99, 99, 98, 98, 99, 99, 99, 99, 20, 85, -86, 13, 2, 99, 99, 99, 99, 99, 99, 99, 85, 12, 85, -86, 13, 2, 99};
String arrStr = Arrays.toString(arr);
System.out.println(arrStr);
List<List<Integer>> list = new ArrayList<List<Integer>>();
List<Integer> temp = new ArrayList<Integer>();
for (int i = 0; i < arr.length; i++) {
if (arr[i] == 85) {
if (temp.size() > 0) {
temp.clear();
}
} else {
}
}
System.out.println("===============");
for (List item : list) {
System.out.println(Arrays.toString(item.toArray()));
}
}

myfc | 园豆：114 (初学一级) | 2021-02-20 12:48

0

echo_lovely | 园豆：911 (小虾三级) | 2021-02-19 17:06
0

您需要登录以后才能回答，未注册用户请先注册