User Tools

Site Tools


java:jfc_intf_set

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
java:jfc_intf_set [2015/03/16 17:02]
gthanos
java:jfc_intf_set [2021/05/22 03:01]
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> 
-Ένα ενδεικτικό τρέξιμο είναι το παρακάτω 
-<code> 
-$> java FindDups2 me you me he he her see me you 
-Unique words:    [see, her] 
-Duplicate words: [you, me, he] 
-</code> 
  
java/jfc_intf_set.txt · Last modified: 2021/05/22 03:01 (external edit)