Check if a value exists in ArrayList

后端 未结 7 2604
长发绾君心
长发绾君心 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:02

    When Array List contains object of Primitive DataType.

    Use this function:
    arrayList.contains(value);
    
    if list contains that value then it will return true else false.
    

    When Array List contains object of UserDefined DataType.

    Follow this below Link 
    

    How to compare Objects attributes in an ArrayList?

    I hope this solution will help you. Thanks

提交回复
热议问题