| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
 买学问 - 大牛一对一辅导，有问必答 买学问 - 专业的付费知识问答平台

已结贴   问题点数：10  回复次数：5

public class zero {

public static void main(String[] args) {
// TODO Auto-generated method stub
int [] oldArr= {1,3,4,0,0,6,6,0,5,4,7,6,7,6,7,0,5};
int [] newArr= {};
int i,j=0,len,len1;
len=oldArr.length;
for(i=0;i<len;i++)
if(oldArr[i]!=0)
{
newArr[j]=oldArr[i];
j++;
}
len1=newArr.length;
for(i=0;i<len1;i++)
System.out.println(" "+newArr[i]);

}

}

得分:3

得分:4

```package com.xiaoa;

public class Zero {
public static void main(String[] args) {
// TODO 牛逼
int[] oldArr = {1, 3, 4, 0, 0, 6, 6, 0, 5, 4, 7, 6, 7, 6, 7, 0, 5};
int[] newArr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
//        int[] newArr = {};
//TODO newArr需要初始化才可以使用
int i, j = 0, len, len1;
len = oldArr.length;
for (i = 0; i < len; i++)
if (oldArr[i] != 0) {
newArr[j] = oldArr[i];
j++;
}
len1 = newArr.length;
for (i = 0; i < len1; i++)
System.out.println(" " + newArr[i]);

}
}
```

得分:3

`int[] newArr={};`
newArr被初始化为{},长度为0.

得分:0

得分:0

• 6
• 1/1页
• 1