Java Generic polymorphism

Source: Internet
Author: User
Tags object object

First-degree Niang a multi-state concept:

polymorphic = = Late binding .

Do not interpret function overloading as polymorphic.

Because polymorphism is a run-time behavior, not a compile-time behavior.

Polymorphic: A reference to a parent type can point to an object of a subtype.

For example, Parent p = new Child ();

    When calling a method using polymorphic mode, first check if there is a method in the parent class, and if not, compile the error;

If so, then call the subclass of the same name method.

(Source: http://www.cnblogs.com/mengdd/archive/2012/12/25/2832288.html)

So what if you want to use generics in Java?

public class ObjectProxy implements Iobject

/**
* Set property values by type
*/
Public <T> T Gettypevalue (Object object, Class<t> typeclass) {}

This can be done in a common Java class, to implement Polymorphic

Related Article

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.