Problems with generics

Source: Internet
Author: User

Today, I found a problem and I don't know what's going on. Please also ask Bo friends to answer.

Here's My Code:

 Package AAA;  Public class a{    }
 Package AAA;  Public class extends a{    }
 Package AAA;  Public class extends b{    }
 PackageAAA;Importjava.util.LinkedList;Importjava.util.List; Public classmain{ Public Static voidMain (string[] args[]) {List<?extendsB> eblist =NewLinkedlist<>(); List<?SuperB> sblist =NewLinkedlist<>(); A A=NewA (); b b=NewB (); C C=NewC ();        Eblist.add (a);    Sblist.add (c); }}

This eblist.add (a); Why did it get an error?

Problems with generics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.