Java Type Erasure Problem

前端 未结 5 2094
一个人的身影
一个人的身影 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 03:58

    Sadly, this is the major area where Java Generics falls down... there is just no good solution.

    I've generally resorted to making a new class, with the interface as Set>, but that wraps Set> (without extending it, which would cause the same problem).

提交回复
热议问题