@@ -0,0 +1,709 @@
+package com.doctor.interview;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0A/**%0A * @see http://howtodoinjava.com/2012/11/09/how-to-find-duplicate-words-in-a-string-in-java/%0A * %0A * @author doctor%0A *%0A * @time 2015%E5%B9%B45%E6%9C%882%E6%97%A5 %E4%B8%8A%E5%8D%8812:19:47%0A */%0Apublic class HowToFindDuplicateWordsInAString %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09String text = %22a r b k c d se f g a d f s s f d s ft gh f ws w f v x s g h d h j j k f sd j e wed a d f%22;%0A%09%09List%3CString%3E list = Arrays.asList(text.split(%22 %22));%0A%0A%09%09Set%3CString%3E set = new HashSet%3C%3E(list);%0A%09%09set.forEach(t -%3E %7B%0A%09%09%09System.out.println(t + %22 : %22 + Collections.frequency(list, t));%0A%09%09%7D);%0A%09%7D%0A%0A%7D%0A

How to find duplicate words in a string in java