我在
行得到以下错误消息' illegal start of expression'抛出FileNotFoundException
我做了一些研究,但没能解决它。你能帮忙吗?非常感谢,zan
import java.io.FileNotFoundException;
import java.io.File;
import java.util.Scanner;
import static java.lang.System.out;
public class training{
public static void main(String[]args){
throws FileNotFoundException{
Scanner diskScanner = new Scanner(new File("occupancy"));
out.println("RoomtGuests");
for(int roomNum = 0; roomNum < 10; roomNum ++){
out.print(roomNum);
out.print("t");
out.println(diskScanner.nextInt());
}
}
}
}
抛出关键字前不应该有大括号:
public static void main(String[]args) throws FileNotFoundException {
^-- no curly brace
throws
使用不当
public static void main(String[]args) throws FileNotFoundException
{
..
}
最好使用try…catch
public static void main(String[]args)
{
try
{
..
}catch(FileNotFoundException ex)
{
//
}
}
你的语法错误。检查您的源代码和/或语言规范