Guest User

Untitled

a guest
Jun 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. public static void main(String[] args) {
  2. String[] a = {"java","c++","c++","java","c#","bootstrap","java"};
  3. Set<String> nonDuplicateSet = new HashSet<String>();
  4. Set<String> duplicateSet = new HashSet<String>();
  5. for(String abc:a){
  6. if(!nonDuplicateSet.contains(abc)){
  7. nonDuplicateSet.add(abc);
  8. }else{
  9. duplicateSet.add(abc);
  10. }
  11. }
  12. System.out.println(duplicateSet);
Add Comment
Please, Sign In to add comment