Santhiya Park Java SE Training Summary (52-) (generics)

Source: Internet
Author: User
  1. Generics: parameterization of variable types
  2. You need to qualify an implementation class for an interface when the subclass of the class is its generic type. For example, T can only be used to implement the type of the List interface <t extend list>
  3. If you do not specify a generic category, you will automatically use <t extend Object>, so you will receive any Java type when not used by default, note: Arrays are also subclasses of Object
  4. There is a custom generic class: generictest<t>{}, now declaring a reference generictest<? Extends list> ge=null;
    This reference means that you can point to a type of generictest, a generic type is an instance of the list interface system, and you can ge= new generictest< arraylist>; or ge= generictest< Linkedlist>
  5. There is a custom generic class: generictest<t>{}, now declaring a reference generictest<? Super List> Ge=null;
    This reference means that you can point to a type of generictest, a generic type is an instance of the list interface system, ge= generictest< collection> but ge= generictest< Linkedlist> will make an error.
  6. Generic use, often see Generictest<? > GE, actually this is generictest< Extends object> GE's abbreviation, meaning that the generic type can be any one of the Java types

Santhiya Park Java SE Training Summary (52-) (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.