Sitemap
Prachi patel

Prachi patel

Exploer and explain language in my own words

An anagram is one of the most important for core java.

Jul 21, 2026
Press enter or click to view image in full size

An anagram means the two words have the same characters , the same character frequecny , but arranged in the different order.

Like..a word is “listen” and the another word is “silent”. There is the same characters are used in the same frequency in a different order.

Let’s understand the code.

When given 2 strings , convert them into arrays.

Then arranged all alphabets into ascending orders of both arrays. using Array.sort(arr1).

Get Prachi patel’s stories in your inbox

Join Medium for free to get updates from this writer.

Now time to check anagrams of these two words.

First check length of words, if they matched, they are anagrams.

After that, we need to check whether the words are anagrams, so we use an if else condition to check both words.

if(Arrays.equals(arr1,arr2))

Here is the complete code to help you understand it more easily.

Feel free to ask any questions.

--

--

Prachi patel
Prachi patel

Written by Prachi patel

Exploer and explain language in my own words