Java 8 generic function should be ambiguous, but failing in runtime

后端 未结 2 1161
星月不相逢
星月不相逢 2021-02-04 18:03

I\'m trying to migrate Java 7 code to Java 8, so I\'ve code similar to:

package tests;

import java.util.Arrays;
import java.util.Map;

public class Tests {
             


        
2条回答
  •  天涯浪人
    2021-02-04 18:31

    Yeah, I have no idea why Java 8 is choosing the overload that takes a map over the one that takes the Comparable vararg. I'm going to guess that good old type erasure is at play here.

    That said, I would just make getString() return a Comparable rather than a T.

提交回复
热议问题