How can I check if a String
is there in the List
?
I want to assign 1
to temp
if there is a result, 2
otherwise.
My current code is:
Integer temp = 0;
List<String> bankAccNos = new ArrayList<String>();//assume list contains values
String bankAccNo = "abc";
for(String no : bankAccNos)
if(no.equals(bankAccNo))
temp = 1;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…