I am getting output from my java program in below format.
[race, care, acre][act, cat]
Expected: Each array elements in different line.
race care acre
act cat
I already tried to print but getting.
race care acre act cat
Is there any way around so i can get expected results. Below is the gist of my code. Thanks
public static void main(String args[]) {
try {
Scanner sc = readWords();
Map<String, List<String>> wordAnagramPairs = new HashMap<>();
wordAnagramPairs = mapAnagrams(sc);
for (String anagram : wordAnagramPairs.keySet()) {
if (wordAnagramPairs.get(anagram).size() > 1) {
System.out.print(wordAnagramPairs.get(anagram));
// for(String anagrams : wordAnagramPairs.get(anagram)){
// System.out.print(anagrams + " ");
// }
}
}
} catch (FileNotFoundException e) {
System.out.println("File Not Found");
}
}