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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:14:24+00:00 2026-05-13T09:14:24+00:00

In Java, am I able to extend from a generic supertype? According to this

  • 0

In Java, am I able to extend from a generic supertype? According to this article, it looks like I should be able to: http://www.ibm.com/developerworks/java/library/j-djc05133.html.

public abstract class MyClass<T> extends T {

However, when I do something similar in my application, I get the following error: “Cannot refer to the type parameter T as a supertype.”

Does anyone know if I am able to extend from a generic supertype in Java? And, if so, is there something special needed to make this happen?

EDIT: I read the article wrong. It’s actually discussing the potential problems of this.

  • 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-13T09:14:24+00:00Added an answer on May 13, 2026 at 9:14 am

    You are able to inherit from a supertype that has generic type parameters. For instance:

    public class MyList<T> extends AbstractList<T>
    

    (or even give the parameters bounds, e.g.):

    public class MyStringList extends AbstractList<String>
    

    You are not able to define a class that has a wildcard supertype. Such a concept doesn’t make any sense in Java (and I’m not convinced it has much value in the abstract). In your MonitoredDevice example, I’m not even sure what functionality you expect there.

    Because of erasure this is simply not possible at a fundamental level of the way Java works. Each class must have a superclass – what is the superclass of MonitoredDevice? What methods are available on a MonitoredDevice object? You wouldn’t be able to call any inherited methods on this class as the compiler could not guarantee such methods exist, nor could the bytecode represent such calls.

    I suspect that what you are trying to do could be better achieved with dynamic proxies.

    Edit: OK, after reading the article fully I can see what the motivation behind such a declaration would be. But after reading the article fully, you also realise that this isn’t supported by Java at present. The fundamental reason why is due to erasure; such a technique would never be possible under the current mechanics, and the article goes into a lot more detail of what specifically prevents this from working.

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

Sidebar

Related Questions

I'd like to know if there is any class in Java able to check,
I'm able to send messages from Java to Websphere MQ on AS400 . If
I need an Android application which should be able to fetch data from the
this is basic example I got for a GUI from a book called Java
I am new to Java coming from a PHP background so sorry if this
Is the Java compiler able to infer the type of a generic static function
I'm able to edit & save data from one Activity(EditActivity.java), but the updated data
Are there simple libraries out there (.NET and Java) that are able to validate
I'm able to read the Manifest file inside of my Java code, but I
I've never been able to get the Java 6 splash screen to work. I've

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.