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:

  • comment on accéde à un element en hashset en java
  • jtree et hashset
  • creation et modification de session java
  • fonction hashset
  • écrire un hashset java
  • creation d'un tableau hashset java
  • modifier un set java
  • hashset parcourir java 1.5
  • javascript toCharArray exemple
  • afficher contenue HashSet java

Leave a Reply

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