当我输入一个简单的代码时,我得到一个我无法理解的错误代码。Java不能找到类
的代码是: 进口静态文件java.lang.System.out;
类UseAccount { 公共静态无效的主要(字串[] 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();”确定了这些类,并且这部分代码下面的信息填充了这些信息。
你有一个类'fred'就是这里访问? – 2011-03-18 16:20:23
你有没有可以到达的地方'fred'?并请发布完整的代码,而不仅仅是一些片段。 – 2011-03-18 16:21:06
你有没有经历过Java中的基本“Hello world”示例?对我来说,你的代码看起来像C++ – bikashg 2011-03-18 16:21:19