How to cast generic List types in java?

后端 未结 9 988
离开以前
离开以前 2020-12-09 17:33

Well, I have a class Customer (no base class).

I need to cast from LinkedList to List. Is there any clean way to do this?

Just so you know, I need to cast it

9条回答
  •  感情败类
    2020-12-09 18:27

    I did this function for that, ugly but it works

    public static  Collection cast(Collection collection, Class clazz){
        return (Collection)collection;
    }
    

提交回复
热议问题