【发布时间】:2014-03-14 00:38:44
【问题描述】:
我有 2 个文件,tweet.java 和 Account.java。当我编译 tweet.java 时,它通过了,但是当我编译 Account.java 时,它说这个错误
C:\Users\Nolan\Documents\OBJECTP\Java\tweet>javac tweet.java
C:\Users\Nolan\Documents\OBJECTP\Java\tweet>javac Account.java
Account.java:8: error: cannot find symbol
private tweet[] UserTweets;
^
symbol: class tweet
location: class Account
Account.java:10: error: cannot find symbol
private final tweet[] EMPTY_TWEET;
^
symbol: class tweet
location: class Account
Account.java:17: error: cannot find symbol
this.UserTweets = new tweet[20];
^
symbol: class tweet
location: class Account
Account.java:18: error: cannot find symbol
this.EMPTY_TWEET = new tweet[0];
^
symbol: class tweet
location: class Account
Account.java:38: error: cannot find symbol
this.UserTweets[TweetCount] = new tweet(message);
^
symbol: class tweet
location: class Account
5 errors
我问过我的教授和很多朋友,他们都不知道问题出在哪里!我在这里处于优势地位,因为我不得不使用我大学实验室的编译器(显然当我编译它时它在那里工作)。
我会把源代码中的方法删减一下。
tweet.java 文件:
//tweet.java
import java.util.Calendar;
public class tweet {
private String message;
private int D;
private int M;
private int Y;
private int H;
private Calendar now;
private int Min;
public tweet(String Mes){
this.message=Mes;
this.now=Calendar.getInstance();
this.D=now.get(Calendar.DATE)+1;
this.M=now.get(Calendar.MONTH);
this.Y=now.get(Calendar.YEAR);
this.H=now.get(Calendar.HOUR);
this.Min=now.get(Calendar.MINUTE);
}
//Method's here
}
Account.java 文件:
//Account.java file
import java.util.Calendar;
public class Account {
private String Username;
private String Password;
private String FirstName;
private String LastName;
private tweet[] UserTweets;
private int TweetCount;
private final tweet[] EMPTY_TWEET;
public Account(String UserName,String Password,String FName,String LName){
this.Username=UserName;
this.Password=Password;
this.FirstName=FName;
this.LastName=LName;
this.UserTweets = new tweet[20];
this.EMPTY_TWEET = new tweet[0];
this.TweetCount=0;
}
//Method's here
}
你能帮帮我吗?
【问题讨论】:
-
这应该可以。您的课程中是否有包声明?
-
我已经执行了你的命令,没有问题。您的
tweet类位于项目的根目录中,而不是在另一个包中? -
编辑:我尝试添加包声明,但没有成功。
标签: java compiler-errors classpath javac symbols