如何在list数组中搜索某一元素值的元素

2025-02-24 02:34:22
推荐回答(1个)
回答1:

import java.util.*;
   
class AlgorithmsDemo {

  public static void main(String args[]) {
   
    List ll = new LinkedList();
    ll.add(1);
    ll.add(2);
    ll.add(3);
    
Integer findValue=2;

if(ll.contains(findValue))
      System.out.println("existed: " + findValue);
    else System.out.println("not existed: " + findValue);
  }
  
}