public static void main(String[] args) {
int i;
float[] npoints = new float[10];
float[] points = new float[10];
points[0]=(float) 0.3;
points[1]=(float) 0.2;
points[2]=(float) 0.4;
points[3]=(float) 0.5;
points[4]=(float) 0.6;
points[5]=(float) 0.0123;
for(i=0;i<6;i++)
{
if(points[i]!=0.0)
{
npoints[i]=points[i];
System.out.println(i+":"+points[i]);
}
}
System.out.println(npoints[i]);
}
输出:
run:
0:0.3
1:0.88
2:0.22
3:0.95
4:0.16
5:0.0123
[0.95, 0.88, 0.3, 0.22, 0.16, 0.0123]
BUILD SUCCESSFUL (total time: 0 seconds)
`
我想在文本文件中打印这个输出,有什么建议吗?我是java新手