开发者

Include an interface from the same package (Java)

I'm new to Java (C++ guy myself) and am trying to compile a 开发者_StackOverflowsimple program (testing different random number algorithms) in Java. I have an interface that I want to use to implement another class with, both of these items are in the same package.

So I have two files right now in my "Random" package directory--"RandomInterface.java" and "RandomTest1.java" (which implements RandomInterface). I can use javac to compile RandomInterface.java just fine, but I get the following error when I then try to compile RandomTest1:

RandomTest1.java:3: cannot find symbol
symbol: class RandomInterface
public class RandomTest1 implements RandomInterface
                                 ^
1 error

I declare both files to be part of the same package (Random) as the first line of each file. What do I need to do to include the RandomInterface class into the compile command for RandomTest1?

Thanks!


Your text says RandomInterface but your code says RandomClass. Is this just a simple oversight, or am I missing something?


In java we use extends keyword for extending class and implements for interface and where as you are using wrong keyword for wrong type. If this is class then you should extends it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜