當我輸入一個簡單的代碼時,我得到一個我無法理解的錯誤代碼。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