就是这段程序,老是出现说:需要";"

来源:百度知道 编辑:UC知道 时间:2024/06/18 18:43:03
谁帮我解释一下这段程序,并说明哪个地方错了
try
{
FileInputStream in=new FileInputStream(args[0]);
BufferedInputStream bufin=new BufferedInputStream(in);
int count,half=bufin.available()/2;
bufin.skip(half);
byte[]buf=new byte[1024];
While((count=bufin.read(buf,0,buf.length))>0)
for(int i=;i<count;i++)
System.out.println((char)buf[i]);

System.out.flush();
bufin.close();
}
一直提示说需要";"

for(int i=;i<count;i++)
System.out.println((char)buf[i]);

你那int i=后面没有值。所以报错
其实看java错误不能只看某一行,可能上面的错误,就能影响下面许多行,有时候报错不准

While((count=bufin.read(buf,0,buf.length))>0)
{
for(int i=;i<count;i++)
{
System.out.println((char)buf[i]);
}
}

养成很好的编程习惯是有很大作用的。

对,即便是一条语句也最好用{}括起来,增加可读性。