How to cast List<Object> to List

后端 未结 16 920
时光取名叫无心
时光取名叫无心 2020-11-27 11:43

This does not compile, any suggestion appreciated.

 ...
  List list = getList();
  return (List) list;


Compil

16条回答
  •  感情败类
    2020-11-27 12:01

    That's because although a Customer is an Object, a List of Customers is not a List of Objects. If it was, then you could put any object in a list of Customers.

提交回复
热议问题