Java generics with unbounded wildcard?

后端 未结 3 1589
孤城傲影
孤城傲影 2021-01-03 13:24

I have an interface to convert object to string:

public interface Converter {
    String asString(T object);
}

And a map to store

3条回答
  •  春和景丽
    2021-01-03 13:59

    You should change the code like this:

    public interface Converter {
        String asString(Object object);
    }
    

    I think it will work.

提交回复
热议问题