I have a dilemma on my hands. After much trial and error, I still could not figure out this simple task.
I have one array
String [] array = {anps, anps, anps, bbo, ehllo};
I need to be able to go through the array and find duplicates and print them on the same line. Words with no duplicates should be displayed alone
The output needs to be like this
anps anps anps
bbo
ehllo
I have tried while, for loops but the logic seems impossible.
HashMap<String, Integer>, where the key is the word, and the value is the counter.