required java.util.ArrayList,found java.lang.Object : I do not understand the reason for this error

前端 未结 7 1278
逝去的感伤
逝去的感伤 2021-01-28 09:30

Following are some snippets from a jsp page:

<%! ArrayList songList = new ArrayList(); %>

    <%
        songList = StoreSongLink.linkLis         


        
7条回答
  •  一生所求
    2021-01-28 10:28

    Your iteration is wrong in

    for (ArrayList list : songList){}
    

    songList contains the list of String elements not the list of ArrayList

    so you need to iterate this way for (Object song: songList){}

    or

    ArrayList songList = new ArrayList();
    for (String song: songList){}
    

提交回复
热议问题