Java 程序不喜欢“扫描仪”这个词
import java.lang.*;
import java.util.*;
import java.io.PrintWriter;
import java.io.FileReader;
import java.io.IOException;
public class Test
{
public static void main(String[] args) throws IOException
{
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
boolean[] correctAnswers = new boolean[20];
infile.close();
}
}
由于某种原因我收到这些错误:
C:\Users\Rawr\Documents\Test.java:11: cannot resolve symbol
symbol : class Scanner
location: class Test
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
^
C:\Users\Rawr\Documents\Test.java:11: cannot resolve symbol
symbol : class Scanner
location: class Test
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
^
2 errors
Tool completed with exit code 1
我不知道发生了什么。 感谢帮助,谢谢。
import java.lang.*;
import java.util.*;
import java.io.PrintWriter;
import java.io.FileReader;
import java.io.IOException;
public class Test
{
public static void main(String[] args) throws IOException
{
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
boolean[] correctAnswers = new boolean[20];
infile.close();
}
}
I'm getting these errors for some reason:
C:\Users\Rawr\Documents\Test.java:11: cannot resolve symbol
symbol : class Scanner
location: class Test
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
^
C:\Users\Rawr\Documents\Test.java:11: cannot resolve symbol
symbol : class Scanner
location: class Test
Scanner infile = new Scanner(new FileReader("historyGrades.txt"));
^
2 errors
Tool completed with exit code 1
I have no idea what's going on.
Help is appreciated, Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是哪个版本的 Java?
Scanner
是在 1.5 中添加的。Which version of Java are you using?
Scanner
was added in 1.5.在命令提示符(终端)上运行以下命令;
如果返回的版本号小于1.5,那么您必须下载新版本的Java。扫描仪类在之前的版本中不可用。从这里下载新版本的SDK;
Java SE 下载
设置新版本后对于 Java,请在源文件中添加以下导入语句;
现在编译你的源代码。现在应该像 F16 一样了。但如有任何问题,请随时询问。
Run the following command on command prompt (terminal);
If the returned version number is less than 1.5 then you have to download the new version of Java. Scanner class is not available in prior versions. Download the new version of SDK from here;
Java SE Downloads
After setting up the new version of Java, add the following import statement in your source file;
Now compile your source. It should go like a F16 now. But feel free to ask in case of any problem.