标签:static 数组 不为 system 基础 sys string java count
import java.util.Arrays;
public class HomeWork04_2 {
public static void main(String[] args){
int [] oldArr={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
int [] newArr= new int[oldArr.length];
int count=0;
for (int i = 0; i < oldArr.length; i++) {
if(oldArr[i]!=0){
newArr[count++]=oldArr[i];
}
}
newArr = Arrays.copyOf(newArr, count);
System.out.println(Arrays.toString(newArr));
}
}
标签:static 数组 不为 system 基础 sys string java count
原文地址:https://www.cnblogs.com/C33baby/p/12781301.html