Java nested wildcard generic won't compile

前端 未结 3 1648
南旧
南旧 2020-12-07 01:20

I have a problem with bounded nested wildcards in Java generics.

Here\'s a common case:

public void doSomething(Set set) {}
         


        
3条回答
  •  无人及你
    2020-12-07 01:48

    So the problem is, doSomething could be implemented as:

    public void doSomething(Map> map) {
        Set set = ...;
        map.put("xyz", set);
    }
    

    You need to decide what you actually mean.

    Probably something like:

    public void doSomething(Map> map) {}
    

提交回复
热议问题