In Java, I want to check whether a String exists in a List<String> myList
.
Something like this:
if(myList.contains("A")){
//true
}else{
// false
}
The problem is myList can contain un-trimmed data:
{' A', 'B ', ' C '}
I want it to return true if my item 'B'
is in the list. How should I do this? I would like to avoid a looping structure.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…