Check if a value exists in ArrayList

后端 未结 7 2535
长发绾君心
长发绾君心 2020-11-27 13:37

How can I check if a value that is written in scanner exists in an ArrayList?

List lista = new ArrayList

        
7条回答
  •  醉梦人生
    2020-11-27 14:15

    Just use .contains. For example, if you were checking if an ArrayList arr contains a value val, you would simply run arr.contains(val), which would return a boolean representing if the value is contained. For more information, see the docs for .contains.

提交回复
热议问题