Cannot find symbol in same package and directory

自闭症网瘾萝莉.ら 提交于 2019-12-01 06:03:56

Change directories to the parent directory of assignment02. You should then be able to use

javac assignment02\Course.java assignment02\Offering.java

or

javac assignment02\Course.java 
javac assignment02\Offering.java

or even

javac assignment02\*.java

The compiler is is looking for the Course class in the assignment02 package FROM your current directory (so when your in the assignment02 directory, it's effectively trying to look in assignment02/assignment02, which obviously isn't right)

While this will correct you current problem you will then get...

assignment02\Offering.java:15: cannot find symbol
symbol  : variable getNumCredits
location: class assignment02.Course
    return course.getNumCredits;
                 ^
1 error

which will need to correct

You need to compile Course.java first—Offering.java depends on it because you referenced it. Also,

public int getNumCredits() {
    return course.getNumCredits;
}

should be

public int getNumCredits() {
    return course.getNumCredits();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!