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:

  • les differentes modification sur une classe dans java
  • hashset qui contient des tableaux java
  • hashset definition java
  • modifier un set java
  • creation d'un tableau hashset java
  • exemple hashset
  • parcourir hashset
  • parcourir hashset java in html
  • manipuler un hashSet
  • appeler hashset dans boucle for java

Leave a Reply

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