Java contains doesn't work as expected because “someString” != “someString”

后端 未结 5 2174
名媛妹妹
名媛妹妹 2021-01-18 15:49

I want check whether a String value val is contained within a List of Strings lets call it stringList.

I am doing this

if(stringList.con         


        
5条回答
  •  迷失自我
    2021-01-18 16:14

    Try the following, first make the check more concrete by iterating the list and checking each element separately. Than, when you hit the elements that you are expecting to be equal, This is what you are supposed to be looking at. Check to see if they are really equal. Maybe there is a case difference? (or some other elusive but plain difference like white space?)

提交回复
热议问题