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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:32:49+00:00 2026-05-26T17:32:49+00:00

From http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeArguments.html#FAQ103 : A wildcard with a lower bound looks like ? super Type

  • 0

From http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeArguments.html#FAQ103:

A wildcard with a lower bound looks like ” ? super Type ” and stands
for the family of all types that are supertypes of Type , type Type
being included. Type is called the lower bound .

So why

ArrayList<? super Number> psupn1 = new ArrayList<Number>();
psupn1.add(new Double(2));

compiled?

Double is not supertype of Number but subclass of Number…

Edit 1:

    ArrayList<? super Number> pextn1 = new ArrayList<Number>();
    psupn1.add(new Integer(2));
    psupn1.add(new Double(2));
    psupn1.add(new Float(2));
    for(Number n : psupn1){ // [Invalid] Number should be change to
    // Object even if I can only add subtype of Number??

    }
  • 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-26T17:32:49+00:00Added an answer on May 26, 2026 at 5:32 pm

    You can add a Double to that, because whatever the type parameter E is, it’s guaranteed to be either Number or a supertype… which means you can definitely convert from Double to E. You wouldn’t be able to do:

    Number x = psupn1.get(0);
    

    though.

    Think about it, and try to create lists which would logically break this. For example, you can’t use:

    // Invalid
    ArrayList<? super Number> psupn1 = new ArrayList<Integer>();
    psupn1.add(new Double(2));
    

    because Integer isn’t either Number or a supertype – it’s a subclass. You can write:

    // Valid
    ArrayList<? extends Number> psupn1 = new ArrayList<Integer>();
    

    … because that’s the other way round. At that point you can write:

    Number x = psupn1.get(0);
    

    because any element in the list is guaranteed to be convertible to Number. It’s all about which way the conversions are required – to the generic type parameter or from it.

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

Sidebar

Related Questions

this is copied from http://www.zenspider.com/ZSS/Products/RubyInline/Readme.html , the home of rubyinline, adding/moding as indicated in
I used the code from http://www.rgagnon.com/javadetails/java-0580.html to get Motherboard Id, but the result is
I wish to capture data from http://www.kitco.com/texten/texten.html : <html> <head> <title>Text Only Market Page</title>
I was reading Code Conventions for Java from http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-137265.html#587 . In that, they have
I’m trying to understand code from http://www.yesodweb.com/book/conduits . After some fixes (like replacing Resource
I have Bass component from http://www.un4seen.com/bass.html . I load mp3 and triying to change
I am querying data from http://www.imdbapi.com and would like to parse the result using
I read from http://www.apple.com/iphone/specs.html that IPhone4's screen is 960-by-640-pixel resolution at 326 ppi. But
I'm installing WordNet in MySQL from http://www.semantilog.org/wn2sql.html I'd like to display the data in
The code below from http://www.scalaclass.com/book/export/html/1 to do matrix dot product. I can't understand the

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.