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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:26:38+00:00 2026-05-22T11:26:38+00:00

I have been searching for quite a while on this, and nothing really comes

  • 0

I have been searching for quite a while on this, and nothing really comes close to what I need.

Example code:

public class MyQueue<E extends Delayed & Serializable> extends DelayQueue<E> {
    private Class<E> mClass;
    public MyQueue(Class<E> type) {
        super();
        mClass = type;
    }
}

MyQueue is created like: MyQueue q<MyObj> = new MyQueue<MyObj>(MyObj.class);.

My question: How can I write the constructor in such a way, that the parameter “type” is of the proper parameterized type “E extends Delayed & Serializable”?

I hope I have explained myself allright.

Thank you in advance for any assistance.

Edit: From the answers and remarks I was at first unable to select a proper answer. So for the first time I shall try to enhance my question with what I wanted in the first place, and what I am ending up with now. Eg answering in the original post what I have found.

Obviously what I need to know, is the class of the parameterized type E on construction time. For transparancy, the queue is using the E class name (being MyObj) to pass to a backing store. After a lot of reading I came to understand that I could not get at this information easier because of type erasure. I was forced to pass the class not only as a parameterized type, but also as a constructor variable.

I was afraid I could, by accident, call the constructor as such (MyObj and OthrObj both implement Delayed & Serializable):

MyQueue q<MyObj> = new MyQueue<MyObj>(OthrObj.Class);

My better question should have been: How can I write the constructor in such a way, forcing the constructor variable E to match the parameterized type E?

It would have made so much more sense, and it probably would have been easier to understand what I have written. Technically most of you are right in some sense, and after testing many of the variations, I came to the conclusion I have already done so giggles sorry seh and Tnem are completly right and both deserve the credits.

  • 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-22T11:26:39+00:00Added an answer on May 22, 2026 at 11:26 am

    What you have written is what you have specified, the type parameter will be enforced to be of type Delayed & Serializable. I can’t see what is wrong here…

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

Sidebar

Related Questions

I have been searching for this for quite a while and couldn't find a
I have been searching for a solution to this for a while and have
I have been searching the answer to this question for a while. It seemed
I've been searching for this for quite a while with no luck so far.
I have been searching this for quite sometime but could not find an appropriate
I've been searching and experimenting for a while with this, but I have had
I have been searching for quite a while now but i am unable to
I've been searching for this for quite a while but can't seem to find
Ok, so I have been searching for quite some time on this. I have
I have been searching about this subject now for quite a few days. And

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.