Java generic class

Source: Internet
Author: User
Tags wrapper

With generics (also called generic), you can write code without knowing the type of the object the code is manipulating. It allows you to create generic classes, constructors, and methods. A generic class is defined using a formal type parameter.
The formal type parameter is a comma-delimited list of variable names placed in the angle brackets after the class name in the class declaration <> .

Grammar

The following code declares a class Wrapper that accepts a formal type parameter:

public class Wrapper<t> {}

In the code, the parameter is named T . Tis a type variable, which can be any reference type in Java, for example: String , Integer , and Double so on.

When you use Wrapper a class, you specify the form type parameter value.

Click on the link to view the details

Java generic class

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.