Question: Write in Java Two words are anagrams if they contain the same letters in the same frequency. For instance, stale and least are anagrams of
Write in Java
Two words are anagrams if they contain the same letters in the same frequency. For instance, stale and least are anagrams of each other. A simple way to check this is to sort the characters in each word; if they get the same answer(in the example, we get aelst), the words are anagrams of each other. Write a Java method that uses the file dictionary.txt as the input and displays each word that is an anagram of each other in a group together. It just needs to read the words in the file as the input then outputs all the words that are anagrams to each other in groups.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
