Netbeans中的项目错误中找不到类

时间:2014-03-17 20:56:00

标签: java netbeans

以下是我的代码:

package student;
public class Student {
private String idNumber;
private int creditHoursEarned;
private int pointsEarned;

public Student(){
        this.idNumber = "9999";
        this.creditHoursEarned = 3;
        this.pointsEarned = 12;
}
        public String getIdNumber() {
        return idNumber;
}
public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
}
public int getCreditHoursEarned() {
        return creditHoursEarned;
}
public void setCreditHoursEarned(int creditHoursEarned) {
        this.creditHoursEarned = creditHoursEarned;
}
public int getPointsEarned() {
        return pointsEarned;
}
public void setPointsEarned(int pointsEarned) {
        this.pointsEarned = pointsEarned;
}
public double calculateGpa() {
        double gradePointAverage = (double)pointsEarned / creditHoursEarned;
        return gradePointAverage;
}
public String toString() {
        return "Student --"+
        "Id Number: " + idNumber+
        ", Credit Hours Earned: " + creditHoursEarned+
        ", Points Earned: " + pointsEarned;
}    
        }

当我尝试在Netbeans IDE 7.4中运行它时,我得到并且错误:

student.Student class wasn't found in Student project

1 个答案:

答案 0 :(得分:0)

最有可能与您的打包结构有关,要么创建一个名为student的新包并将此类保存在其中,要么尝试从文件顶部删除package student;