-1
符號在那裏是「;」,所以我不確定語法上的問題是什麼。第17行接收「找不到符號錯誤」
//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();
Scanner localScanner = new Scanner(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
如果需要我也有 「狗」 類的源代碼。 我在想什麼/遺忘?
在類文件的頂部添加'import java.util.Scanner'。 –