Java Generic Class - Determine Type

前端 未结 8 2123
野性不改
野性不改 2020-11-27 12:48

If I am creating a java class to be generic, such as:

public class Foo

How can one determine internally to that class, what \'T\

8条回答
  •  不知归路
    2020-11-27 13:27

    The Problem is that most of the Generic stuff will disappear during compilation.

    One common solution is to save the type during the creation of the Object.

    For a short introduction in the Type Erasure behaviour of java read this page

提交回复
热议问题