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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:37:15+00:00 2026-06-15T08:37:15+00:00

I am having some problems with my syntax. I am looking all over and

  • 0

I am having some problems with my syntax. I am looking all over and could not find the correct thing (I actually do not know, what would be the phrase to search). So here is the problem. For simplicity, lets assume I have 4 classes:

class A:

public abstract class A{
}

class B:

public class B extends A{
    //some methods and fields
}

class C:

public class C extends A{
    //some other methods
}

class D:

public class D{
    protected ? value;
}

Here I have a problem, because I do not know what to put instead of ? in class D, if I want to define ? as some sub-class of A. I know an option is just to write A instead of ?, but I think that this could be more specified, for example something like <T extends A>.

Is this even possible?

-edit-

From answers below, I saw that approach would be, to use raw types. But nevertheless, can anyone confirm that a construct like this, does not exist in java? That you could create a field of generic type T (extending some class), but the class containing this field does not have a generic parameter T?

  • 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-15T08:37:16+00:00Added an answer on June 15, 2026 at 8:37 am

    Use a generic class as follows:

    public class D<T extends A> {
        protected T value;
    }
    

    MyClass isn’t dependent of T as you pretend in your comment above. You can instantiate an instance without precising wildcard. Therefore, T would still be remplaced by A at compile-time
    This concept is called: Raw types

    For more information: http://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html

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

Sidebar

Related Questions

I'm having some problems while using PDO. It all seems correct but I am
Having some problems with syntax here. Trying to get like counts on any page
I'm practicing object oriented syntax in javascript and am having some problems. This is
I am having some tricky problems with Irony which I do not understand... The
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
Im having some problems with a simple toggle in Safari. A really annoying flickering
I am having some problems with the PDF files that I make using the
I'm having some problems trying to figure out how to generate a Google Map
I'm having some problems building an hierarchistic array structure - I have almost got

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.