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

  • SEARCH
  • Home
  • 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 7518519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:45:40+00:00 2026-05-30T01:45:40+00:00

I have run into a problem with generics in Java and I can’t find

  • 0

I have run into a problem with generics in Java and I can’t find a solution or example online of someone using generics in a similar fashion. I have a set of methods that are in the same request/response structure. For example, a user populates fields in the Request object, passes the object to a helper method, and they are returned a Response object. All of my request objects extend from a common Request super class (and similarly, Response objects from a Response super class). I would like my helper classes to also have a consistent structure so I have used an interface. Here is some code to illustrate…

Request super class:

public class SuperRequest {
    // ...
}

Example Request subclass:

public class SubRequest extends SuperRequest {
    // ...
}

Response super class:

public class SuperResponse {
    // ...
}

Example response subclass:

public class SubResponse extends SuperResponse{
    // ...
}

The interface:

public interface SomeInterface {
    public <T extends SuperRequest, U extends SuperResponse> U someMethod(T request);
}

As you can see from the interface, I want to pass an object that is a child of SuperRequest and I want to return an object that is a child of SuperResponse. Here is my implementation:

public class SomeImplementation implements SomeInterface {

    @Override
    public SubResponse someMethod(SubRequest request) {
        return null;
    }
}

In Eclipse, I get compilation errors because the compiler tells me I have unimplemented methods and the @Override notation “does not override a supertype method”.

Can anyone help me here? Is my syntax incorrect or is my understanding of generics a little off? Any help is greatly appreciated!

  • 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-05-30T01:45:41+00:00Added an answer on May 30, 2026 at 1:45 am

    Try changing your interface and implementation to:

    interface SomeInterface<T extends SuperRequest, U extends SuperResponse> {
        public U someMethod(T request);
    }
    
    class SomeImplementation implements SomeInterface<SubRequest, SubResponse> {
    
        @Override
        public SubResponse someMethod(SubRequest request) {
            return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just installed VS2008 and have run into a problem that I'm sure can
I'm using SWFUpload to handle file uploads and have run into a problem where
I have run into a problem with generics and new members. I wrote a
I have run into a problem using PDO because an error was not caught.
I have run into this problem before but never quite solved it. I have
I have run into a problem trying to modify a form I myself have
I have run into a problem w/ my model for databinding in WPF. I
I have run into a problem... I'm trying to use QTKit in an application
it seems I have run into a problem with Internet Explorer 7. I have
I am developing an xbap application and have run into a problem with users

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.