Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8010509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:45:23+00:00 2026-06-04T18:45:23+00:00

I have classes A, B with B extends A I have interface defined as

  • 0

I have classes A, B with B extends A
I have interface defined as

public interface MyProcessor<EVENT> {
     void processEvent(EVENT event);
}

I have two implementations

public class EventAProcessor implements EventProcessor<A> {
    @Override
    public void processEvent(A a) {
}
public class EventBProcessor implements EventProcessor<B> {
    @Override
    public void processEvent(B b) {
}

there is common processing so I decided to extend BProcessor from Aprocessor

public class EventBProcessor extends EventAProcessor implements EventProcessor<B> {

    }

This is where it fails with the message

 MyProcessor cannot be inherited with different arguments: <A> and <B>

I have other solutions to workaround my problem, but just wondering, how to get this working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:45:24+00:00Added an answer on June 4, 2026 at 6:45 pm

    You should introduce an abstract generic class:

    public abstract class AbstractEventProcessor<EVENT> 
      implements EventProcessor<EVENT> {
    
      // Put your common logic here
    }
    

    Your other classes will then inherit common functionality as such:

    public class EventAProcessor extends AbstractEventProcessor<A> {}
    public class EventBProcessor extends AbstractEventProcessor<B> {}
    

    This doesn’t necessarily have to do with generics. It’s a general way to approch polymorphism in object-oriented programming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created 2 classes as follows... public class A extends JFrame { public
I have the following hierarchy of classes: public interface Message public interface V2Message extends
Suppose I have two Classes, A and B. The A class is defined as
I have a few classes such that: public class XMLStatusMessage extends XMLMessage {} public
I have some classes that look like this: MODEL public abstract class BaseEntity<O extends
I have two classes public class PrepaidPackage { private String name; private String serviceClassID;
I have the following classes : public interface Factory<T extends MyParentClass> { public T
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine
If I have three classes class A class B extends A class C extends
I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.