Java-source: Vérifier si un élément existe dans HashSet

Author:

Java-source: Vérifier si un élément existe dans HashSet
{filelink=438}

/***** Code de MesExemples.com *******/
import java.util.HashSet;

 class VérificationHashSet
 {

public static void main(String[] args) {

// créer un objet HashSet
HashSet hashSet = new HashSet();
hashSet.add(new Integer("1"));
hashSet.add(new Integer("2"));
hashSet.add(new Integer("3"));



boolean blnExists = hashSet.contains(new Integer("3"));
System.out.println("3 exist-il dans HashSet ? : " + blnExists);

}
}

/*
3 exist-il dans HashSet ? : true
*/

A Voir sur le même Sujet:

  • source java (interface qui verifie user et password )
  • hashset java tester existence

Leave a Reply

Your email address will not be published. Required fields are marked *