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 8144083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:16:36+00:00 2026-06-06T13:16:36+00:00

I have some troubles with a method having a typed List parameter, inherited from

  • 0

I have some troubles with a method having a typed List parameter, inherited from another (typed) class.

Let’s keep it simple :

public class B<T> {
  public void test(List<Integer> i) {
  }
}

The B class has a useless generic T, and test() want an Integer List.

Now if I do :

public class A extends B {
  // don't compile
  @Override
  public void test(List<Integer> i) {
  }
}

I get a “The method test(List) of type A must override or implement a supertype method” error, that should not happen.

But removing the type of the list works… although it doesn’t depend on the class generic.

public class A extends B {
  // compile
  @Override
  public void test(List i) {

And also defining the useless generic below to use the typed list

public class A extends B<String> {
  // compile
  @Override
  public void test(List<Integer> i) {

So I’m clueless, the generic of B should have no influence on the type of the test() list. Does anyone have an idea of what’s happening?

Thanks

  • 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-06T13:16:38+00:00Added an answer on June 6, 2026 at 1:16 pm

    You’re extending the raw type of B, not the generic one. The raw one effectively does not have a test(List<Integer> i) method, but a test(List) method.

    If you switch to raw types, all generics are replaced by raws, regardless of whether their type was filled in or not.

    To do it properly, do

     public class A<T> extends B<T>
    

    This will use the generic type B<T>, which includes the method you want to override.

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

Sidebar

Related Questions

I have some troubles with my school project. I have a class: #include Group.h
I have some troubles with getting the data from the website. The website source
I have some troubles while writing logs from log4net to the file. I seem
I'm having some trouble writing a hashCode() method for a class I created. This
I am having a lot of troubles with method overloading here and have no
Dear HTML5 developers, I'm having some troubles with this HTML5 audio... So let's jump
I'm having some trouble figuring out to call methods that I have in other
I have some troubles with plotting the figure. I have a file with some
I have some troubles mapping a JSON Array to RestKit. This is what the
I have some troubles with positioning my label/password field. With this code they both

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.