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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:01:15+00:00 2026-05-18T20:01:15+00:00

I want to provide something like this in my api: class Foobar extends AbstractThing<Double>

  • 0

I want to provide something like this in my api:

class Foobar extends AbstractThing<Double>

class EventThing<Foobar> {    
            public Foobar getSource();
            public Double getValue();
}

So I write this:

class EventThing<T extends AbstractThing<U>> {    
        public T getSource();
        public U getValue();
}

But java can not resolve the U.

With EventThing<T extends AbstractThing<U>,U> instead it works, but the second U is actually redundant ’cause the AbtractThing define the Type already. So I love to get rid of it.

  • 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-18T20:01:16+00:00Added an answer on May 18, 2026 at 8:01 pm

    You can’t get rid of it. The second U is not redundant. You want the compiler to interpret the first U as a type parameter, but it doesn’t. You could also have written this:

    class EventThing<T extends AbstractThing<Double>>
    

    Note that Double in this case is a concrete class, and not a type parameter. Compare this to the following:

    class EventThing<T extends AbstractThing<U>>
    

    Note that this has the exact same form as the first line of code above. How is the compiler supposed to know that in the first case, Double is meant as a concrete class, while in the second case, U is meant as a type parameter?

    The compiler can’t know that, and treats the U as a concrete class, just like the Double in the first line. The only way to let the compiler know that U is a type parameter is to specify it as such:

    class EventThing<T extends AbstractThing<U>, U>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to provide something like this in my api: class Foobar extends AbstractThing<Double>
So how to create something which would have something like this in its api:
I want to do something like this: <?php echo date('Y'); ?> But then in
I'm working on a resource management class and want to have the user provide
So, I have this public API that my application exposes, allowing customers to write
I want to provide silverlight app to my customer while hosting the app at
I want to provide a piece of Javascript code that will work on any
I want to provide dynamic download of files. These files can be generated on-the-fly
If I want to provide OpenID as the only registration method available AND want
Say you have an app, that you want to provide users ability to browse

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.