Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Generics Wildcard array of references?

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Generics Wildcard array of references?

    An array of references to a specific generic type is not allowed in Java.
    e.g.,
    ArrSpec<String> arrs[] = new ArrSpec<String>[10];
    is not allowed though the type checkng and memory allocation can be done at the compile time itself.

    Instead of this, Java allows to use Wildcard type array of references to a generic type.
    e.g.,
    ArrSpec<?> arrs[] = new ArrSpec<?>[10];
    is allowed though the type checking, memory allocation and any type of values to be stored would be decided at the runtime.

    This above behavior is confusing and needs more clarification!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Generics Wildcard array of references?

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    You appear to be quoting a Java reference. Please provide a link to the reference or a title plus version number if it is not available on the web.

    The best way to eliminate confusion is to write code.

    Good luck!

Similar Threads

  1. Replies: 1
    Last Post: July 1st, 2013, 08:36 AM
  2. Replies: 1
    Last Post: November 2nd, 2012, 04:56 AM
  3. [SOLVED] wildcard delete
    By macko in forum What's Wrong With My Code?
    Replies: 13
    Last Post: November 1st, 2011, 03:31 PM
  4. Web service references
    By Eggbert in forum Java IDEs
    Replies: 3
    Last Post: October 25th, 2011, 06:46 AM
  5. Averaging Numbers in an Array Based on References
    By aussiemcgr in forum Java Theory & Questions
    Replies: 6
    Last Post: August 6th, 2010, 06:39 PM

Tags for this Thread