接收"找不到符号错误"在第17行

时间:2013-08-31 01:42:06

标签: java

符号在那里是“;”,所以我不确定语法中的问题是什么。

//Vet Application
import java.io.PrintStream;

public class VetApp
{
public static void main(String[] paramArrayOfString)
{
Dog newDog1 = new Dog();
Dog newDog2 = new Dog(2, "Ruff");
System.out.println();

System.out.println();
newDog1.print();
System.out.println();
newDog2.print();

扫描程序localScanner =新扫描程序(System.in);

System.out.print("What is the new breed of the first dog? ");
int i = localScanner.nextInt();
newDog1.setBreed(i);
System.out.println();
System.out.println();
newDog1.print();

System.out.print("What is the breed of the second dog? ");
i = localScanner.nextInt();
newDog2.setBreed(i);
System.out.println();
System.out.println();
newDog2.print();

System.out.print("What sound does the first dog make? ");
String str = localScanner.next();
newDog1.setSound(str);
System.out.println();
System.out.println();
newDog1.print();

(部分程序被省略)

以下是错误消息:

c:\jwork>javac VetApp.java
MontelWhite_VetApp.java:17: error: cannot find symbol
Scanner localScanner = new Scanner (System.in);
^
symbol:   class Scanner
location: class VetApp
MontelWhite_VetApp.java:17: error: cannot find symbol
Scanner localScanner = new Scanner (System.in);
                           ^
symbol:   class Scanner
location: class VetApp
2 errors

如果需要,我还有“Dog”类源代码。 我错过/遗忘了什么?

1 个答案:

答案 0 :(得分:1)

您忘记添加java.util.Scanner的导入。因此,将其添加到您的类文件之上,如下所示:

import java.util.Scanner;
import java.io.PrintStream;

public class VetApp {
    /* Code omitted */
}