Java: Création, modification et affichage d’un HashSet

Author:

 int,string,char,static, url, socket, url, socket, java
{filelink=23}


import java.util.*;
/*
 *  Création, modification et affichage d'un HashSet
 *
 **/
public class ExempleHashSet 
{
   
   public static void main (String[] args) 
   {
   	// Créer une HashSet avec une capacité initiale
   	Set s1 = new HashSet(8);
   	 int hash = 0;
   	 String str="abnghtpo";
     for (char ch : str.toCharArray()) 
       {
          hash = hash * 31 + ch;
          s1.add(hash);
        }
      
      // Afficher le contenu de HashSet
      Iterator iter=s1.iterator();
      while(iter.hasNext())
      {
      	System.out.println (iter.next());
      }

   }

}

A Voir sur le même Sujet:

  • boucle sur hashset
  • javascript toCharArray exemple
  • modifier un set java
  • fonction hashset
  • comment prelever un caractere d'un tableau hashset
  • exemple hashset
  • parcourir HashSet
  • parcourir hashset
  • hashset parcourir java 1.5
  • afficher hashset

Leave a Reply

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