-1

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

//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”类源代码。我错过/忘记了什么?

4

1 回答 1

1

您忘记为java.util.Scanner. 所以将它添加到你的类文件的顶部,如下所示:

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

public class VetApp {
    /* Code omitted */
}
于 2013-08-31T01:44:12.880 回答