foreach not applicable to expression type

前端 未结 3 1436
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-11 18:39

what does this error mean? and how do i solve it?

foreach not applicable to expression type.

im am trying to write a method find(). that find a string in a l

3条回答
  •  遥遥无期
    2021-01-11 19:33

    Make sure your for-construct looks like this

        LinkedList stringList = new  LinkedList();
        //populate stringList
    
        for(String item : stringList)
        {
            // do something with item
        }
    

提交回复
热议问题