当我输入一个简单的代码时,我得到一个我无法理解的错误代码。
代码是: import static java.lang.System.out;
类UseAccount { public static void main(String [] args) {
fred myAccount = new fred();
fred yourAccount = new fred();
myAccount.name = "Barry Burd";
myAccount.address = "222 Cyberspace Lane";
myAccount.balance = 24.02;
yourAccount.name = "Jane Q. Public";
yourAccount.address = "111 Consumer Street";
yourAccount.balance = 55.63;
myAccount.display();
out.println();
yourAccout.display();
}
}
然而,当我尝试编译代码时,我得到:
account2.java:9: cannot find symbol
symbol : class fred
location: class UseAccount
fred yourAccount = new fred();
^
如何解决此错误?
我刚刚开始学习java,这段代码直接来自教程。根据教程使用“fred myAccount = new fred();”并且“fred yourAccount = new fred();”确定了类,并且这段代码下面的信息填写了信息。
答案 0 :(得分:3)
在你的代码中的某个地方,你需要一个文件Fred.java(你应该使用大写字母名称,尽管java不需要它)至少
class Fred {
}
然后你需要填写它以使它做某事。
更好的是,将帐户命名为。
答案 1 :(得分:1)
您需要使用已编译的类fred
编译您的类。
您是否考虑过使用IDE,它可以帮助您开始编写代码,父亲。
答案 2 :(得分:0)
能够成功编译: