write the program that return duplicate words from given string.
Anonym
import java.util.*; class Duplicates{ public static void main(String[] args) { String st = "Here it is two sentences two two two"; String starr[] = st.split(" "); int count = 1; HashMap map = new HashMap(); int temp = 1; for (String st1 : starr ) { if(map.containsKey(st1)) { temp = map.get(st1); temp++; } map.put(st1,temp); temp = 1; } System.out.println(map); } }