Check if two strings are anagrams or not in java

By | July 22, 2018

This post is all about write a java program to check if two strings are anagrams or not in java

Write a Java program to find whether the given strings are anagrams or not is a very frequently asked interview question these days no matter how much experience do you have.

What is an anagram?

We can say that two strings are called anagrams if we can rearrange the letters of one string to produce the second string, using all the letters of the first string only once. While doing that, usually, you don’t consider spaces and punctuation marks.

Few examples  Like-“Listen”and “Silent”,forty five” and “over fifty”, “restful” and “fluster”

If you run above program in your favourite IDE then you will get blow output:

You would love to watch me on YouTube:

That’s all about this post How to check  if two strings are anagrams or not in java.

You May Also Like:

Reverse a string in Java (6 Different Ways)
Splitting a String in Java using a delimiter
Count number of words in a string java
Count total number of times each character appears in the string in java
How to convert string to int without using library functions in java
Check Whether a Given String/Number is a Palindrome in java
How to find first non-repeated character in a given String in Java
How to find first non-repeatable character from a String using Java 8
Java Program to find the frequency of each character in String ?

If you have any feedback or suggestion please feel free to drop in below comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *