fork download
  1.  
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class MyDuplicateEntry {
  8.  
  9. public static void main(String a[]){
  10. String[] strArr = {"one","two","three","four","four","five"};
  11. TreeSet<String> unique = new TreeSet<String>();
  12. for(String str:strArr){
  13. if(!unique.add(str)){
  14. System.out.println("Duplicate Entry is: "+str);
  15. }
  16. }
  17. }
  18. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
Duplicate Entry is: four