Check if a String is in an ArrayList of Strings
arraylist, java, list, string
Solution
temp = bankAccNos.contains(no) ? 1 : 2;
Problem
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; ```