Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- String[] a = {"java","c++","c++","java","c#","bootstrap","java"};
- Set<String> nonDuplicateSet = new HashSet<String>();
- Set<String> duplicateSet = new HashSet<String>();
- for(String abc:a){
- if(!nonDuplicateSet.contains(abc)){
- nonDuplicateSet.add(abc);
- }else{
- duplicateSet.add(abc);
- }
- }
- System.out.println(duplicateSet);
Add Comment
Please, Sign In to add comment