I wrote up a CombatHandler class.

Here is what the begining:

public class CombatHandler extends client {

But when I compile I get this error:

Running Compiler
--------------------------------------
CombatHandler.java:3: cannot find symbol
symbol  : constructor client()
location: class client
public class CombatHandler extends client {
       ^
Note: stream.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
Press any key to continue . . .

Can anyone help?

Dani AI

Generated

The compiler message indicates the subclass constructor is trying to call a superclass no-argument constructor that isn’t available. Java inserts an implicit super() at the start of any constructor that does not explicitly call another superclass constructor. If the parent class only defines constructors with parameters, that implicit call fails. was right to flag case sensitivity (class names must match exactly), and correctly pointed toward missing no-arg constructors and package/visibility issues.

Practical fixes:

  • Add a no-arg constructor to the parent class so the implicit super() can succeed:
public class Client {
    public Client() { /* default init */ }
    public Client(String cfg) { /* parameterized */ }
}
  • Or provide a constructor in the subclass that calls an existing superclass constructor explicitly:
public class CombatHandler extends Client {
    public CombatHandler(String cfg) {
        super(cfg); // match an existing constructor in Client
    }
}

Other checks and troubleshooting tips:

  • Confirm the parent is actually a class (not an interface). If it is an interface use implements instead of extends.
  • Ensure the parent constructor you call is accessible (public/protected) from the subclass package.
  • Make sure the class name and file name capitalization match (Client.java for public class Client) and that the parent class is on the classpath when compiling.
  • If the parent is abstract, implement required abstract methods or declare the subclass abstract.

For authoritative details on how constructors and superclass calls work, see the Java tutorials on constructors and inheritance: Java Constructors and Inheritance and Subclasses.

Recommended Answers

All 2 Replies

1. client class/interface does not exist
2. client class/interface does exist BUT with an uppercase "C"

> Can anyone help? help

Check if the Client class has a no-arg constructor in case you have explicitly provided a overloaded constructor. Also, looking at the error message gives an indication that you are not placing your class in a package. Make it a habit to put your classes in packages, *always*.

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.