Java - Generics with lists

后端 未结 5 1020
悲&欢浪女
悲&欢浪女 2020-12-21 13:52

I wrote a function for my cache to retrieve a specific object. This way I don\'t need to cast it .

@SuppressWarnings(\"unchecked\")
    public static 

        
5条回答
  •  一个人的身影
    2020-12-21 14:17

    You can't get class of List, in your case the only way is:

    List ipList = (List)Util.inCache(List.class, title);
    

提交回复
热议问题