简体   繁体   中英

Beginner Importing in Dr. Java

Trying to import a class I made in Dr. Java. I made a simple class called QuestionObject which has String questionString and an array for answers and then an int which corresponds to the correct answer and corresponding getters, setters, and constructors. Compiles fine. In my other class file, the one with my main method and such called Game , when I try import QuestionObject; I get a 'cannot resolve' error in the compiler. I saved the class in the same folder as Game.java. Doing everything in OS X not using command line.

Help please! There's probably a simple answer, I just can't find it!

Don't import the class if both classes are in the same directory and in the default package! Try removing the import statement.

Try setting the package of both classes. And make sure that both classes are in the class path. I am not familiar with Dr Java but with the command line compiler javac *.java in the directory with the classes should pickup both classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM