How to cast List<Object> to List

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

This does not compile, any suggestion appreciated.

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


Compil

16条回答
  •  清歌不尽
    2020-11-27 12:23

    Depending on your other code the best answer may vary. Try:

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

    or

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

    But have in mind it is not recommended to do such unchecked casts.

提交回复
热议问题