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

前端 未结 7 1281
逝去的感伤
逝去的感伤 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<String> list : songList){}
    

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

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

    or

    ArrayList<String> songList = new ArrayList<String>();
    for (String song: songList){}
    
    0 讨论(0)
提交回复
热议问题