java:jfc_intf_set

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:jfc_intf_set [2015/03/16 17:00]
gthanos created
java:jfc_intf_set [2016/02/26 11:15]
Line 1: Line 1:
-====== Set ====== 
- 
-Το //Set// είναι ένα Collection το οποίο δεν επιτρέπει διπλές εγγραφές. Δείτε το παρακάτω παράδειγμα κώδικα 
- 
-<code java FindDups2.java>​ 
-public class FindDups2 { 
-  public static void main(String[] args) { 
-    Set<​String>​ uniques = new HashSet<​String>​();​ 
-    Set<​String>​ dups    = new HashSet<​String>​();​ 
- 
-    for (String a : args) 
-      if (!uniques.add(a)) 
-        dups.add(a);​ 
- 
-    // Destructive set-difference 
-    uniques.removeAll(dups);​ 
- 
-    System.out.println("​Unique words: ​   " + uniques); 
-    System.out.println("​Duplicate words: " + dups); 
-  } 
-} 
-</​code>​ 
  
java/jfc_intf_set.txt · Last modified: 2016/02/26 11:15 (external edit)