April 05
Prde. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
Exemplo HashSet
npublic class FindDups {
n  public static void main(String args[]) {
n    Set<String> s = new HashSet<String>();
n    for (int i=0; i<args.length; i++)                  // Com for-each fica ....
n      String a = args[i];                                     // for( String a : args )
n      if ( ! s.add(a) )
n         System.out.println("Duplicata encontrada: "  + args[i]);
n      System.out.println(s.size()+"palavras distintas encontradas:"+s);
n   }
n}
nExecução:
n% java FindDups i came i saw i left
nDuplicata encontrada: i
nDuplicata encontrada : i
n4 palavras distintas encontradas: [came, i, left, saw]
target =
"_self" - show in the current frame
"_parent" - show in the parent frame
"_top" - show in the topmost frame
"_blank" - show in a new unnamed top-level window
name - show in a new top-level window named name