Java Type Erasure Problem

前端 未结 5 2095
一个人的身影
一个人的身影 2021-02-11 03:11

I\'ve made an example to demonstrate my problem:

Metrical.java

public interface Metrical
{
    double distance(T other);
}
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-11 04:15

    I've written an article about type erasure which can be of your interest. It gives the common widely known solution and also a tricky way to circumvent the problem. I don't know if it will be relevant for you. Anyway, it contains some techniques which may be useful under certain circumstances.

    See also: Using TypeTokens to retrieve generic parameters

    I hope it helps.

提交回复
热议问题