I am trying to call an external class with the following line

class "classname" implements "another classname" {

..I however keep getting an "Interface expected here" error at compilation. What am doing wrong, please?

Recommended Answers

All 5 Replies

Well, is the "other classname" an interface? The declaration expects you to have an interface name there, which your class implements. When you say "call " an external class, what exactly are you trying to do?

I have two .java files (with with a main method and one without). My goal is to call the class without main for use in the one with a main method.

You don't need to "implement" that class then. You just need to declare an object of that type and use whatever methods you need on it.

Ok. Thank you Ezzaral, I will give that a try.

you need to extend instead...

public class SecondClass extends FirstClass
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.