List cannot be converted to ArrayList

前端 未结 3 1815
迷失自我
迷失自我 2021-01-06 12:39

At the beginning of my code, there is:

List> result = new ArrayList();

And then, (here is to reverse a sub-list):

3条回答
  •  我在风中等你
    2021-01-06 13:11

    It's because your result varible has a type of List, but your method want an ArrayList Try it with:

    List result = new ArrayList<>();
    

    or change your function in:

    public List reverse(List list){...
    

提交回复
热议问题