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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:34:57+00:00 2026-06-04T09:34:57+00:00

I have the following class structure: public abstract class Generic<T extends SuperClass> public class

  • 0

I have the following class structure:

public abstract class Generic<T extends SuperClass>

public class SuperGeneric<T extends SuperClass & SomeInterface> 
    extends Generic<T>

Now I want to make an instance of SuperGeneric covering all possible classes. I tried it like this:

Generic<? extends SuperClass & SomeInterface> myGeneric 
    = new SuperGeneric<? extends SuperClass & SomeInterface>();

Now this doesn’t seem to work.
On Generic it gives the following error: Incorrect number of arguments for type Generic<T>; it cannot be parameterized with arguments <? extends SuperClass, SomeInterface>.

And on the new SuperGeneric I get a similar error: Incorrect number of arguments for type SuperGeneric<T>; it cannot be parameterized with arguments <? extends SuperClass, SomeInterface>.

Any idea how to correctly create instances of this SuperGeneric?

The idea is that I have 2 different classes that satisfy the extends SuperClass & SomeInterface condition but those cannot be generalized by one type.

  • 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-04T09:34:59+00:00Added an answer on June 4, 2026 at 9:34 am

    When you want to instantiate a generic class, you need to provide the concrete type. You said there are two classes that fulfill the constraint. Say these are Type1 and Type2.

    Then you should be able to do:

    Generic<Type1> myGeneric1 = new SuperGeneric<Type1>();
    

    and

    Generic<Type2> myGeneric2 = new SuperGeneric<Type2>();
    

    The wildcards are used only for declaration. They mean: You can put any type here (that fulfills the given constraints)

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

Sidebar

Related Questions

I have the following structure: abstract class Base { public abstract List<...> Get(); //What
I have following structure of my entities: @MappedSuperclass public abstract class BaseEntity { @Id
I have the following class structure public class Outer{ private Mapper a; .... private
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have following code: public abstract class Operand<T> { public T Value { get;
I have a follwing class structure: public abstract class AbstractFoo { public virtual void
I have following class structure public class Limit { public double MinSelectedValue; public double
Let's say I have the following class structure (simplified from my real-world problem): Public
I want to have the following class structure: #include <tr1/memory> class Interface; class Impl;
I have the following classes (trimmed to only show the basic structure): public abstract

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.