i need to find a integer data in arraylist?

后端 未结 4 771
抹茶落季
抹茶落季 2020-12-16 14:26

I have an Arraylist. If user enter the same number secondly I want to show to user. For this I need to find Arraylist have it or not.

I hop

4条回答
  •  猫巷女王i
    2020-12-16 14:31

    No, you have not. But here's my best guess:

    List values = Arrays.asList( 1, 2, 4, -5, 44 );
    int userValue = 44;
    if (!values.contains(userValue)) {
        values.add(userValue);
    }
    

提交回复
热议问题