DashRantic
DashRantic

Reputation: 1518

Include an interface from the same package (Java)

I'm new to Java (C++ guy myself) and am trying to compile a simple 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!

Upvotes: 0

Views: 1117

Answers (2)

AZ_
AZ_

Reputation: 21899

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.

Upvotes: 0

Carl Smotricz
Carl Smotricz

Reputation: 67790

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

Upvotes: 1

Related Questions