XhstormR
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Test {
public static void main(String[] args) {
int[] ints = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
Integer[] integers = arrays(ints);
System.out.println(Arrays.toString(integers));
}
public static Integer[] arrays(int[] ints) {
List<Integer> list = new ArrayList<>();
for (int i = 0; i < ints.length; i++) {
if ((i + 1) % 2 != 0) {
list.add(ints[i]);
}
}
return list.toArray(new Integer[list.size()]);
}
}代码以上,望采纳。