how to find two strings are anagrams in java

Solutions on MaxInterview for how to find two strings are anagrams in java by the best coders in the world

showing results for - "how to find two strings are anagrams in java"
Florent
27 Jan 2020
1import java.util.Arrays;  
2   
3public class AnagramString {  
4    static void isAnagram(String str1, String str2) {  
5        String s1 = str1.replaceAll("\\s", "");  
6        String s2 = str2.replaceAll("\\s", "");  
7        boolean status = true;  
8        if (s1.length() != s2.length()) {  
9            status = false;  
10        } else {  
11            char[] ArrayS1 = s1.toLowerCase().toCharArray();  
12            char[] ArrayS2 = s2.toLowerCase().toCharArray();  
13            Arrays.sort(ArrayS1);  
14            Arrays.sort(ArrayS2);  
15            status = Arrays.equals(ArrayS1, ArrayS2);  
16        }  
17        if (status) {  
18            System.out.println(s1 + " and " + s2 + " are anagrams");  
19        } else {  
20            System.out.println(s1 + " and " + s2 + " are not anagrams");  
21        }  
22    }  
23   
24    public static void main(String[] args) {  
25        isAnagram("Keep", "Peek");  
26        isAnagram("Mother In Law", "Hitler Woman");  
27    }  
28}  
29/*OUTPUT
30*Keep and Peek are anagrams
31*MotherInLaw and HitlerWoman are anagrams
32*/
queries leading to this page
checking anagrams 28check whether two string is anagrams or not 29string anagram checkcheck if a string is anagramanagram java programanagram tester javawhat is an anagram stringhow to check the anagrams for string in javahow to determine if two strings are anagram of one another in javadetermine whether two words are anagramsjava are anegramsjava check if two strings are anagrams2 sting anagram javaprogram to find if two strings are anagramsjava anagram checkeranagrams in javawrite a simple anagram detector javawhat is mean by the anagrams in javacheck two strings are anagramwhat is an anagram of stringhow do you check if two strings are anagrams of each other in javajava program to check whether a string is anagram or notanagram program javacheck if a string is an anagramjava program to check if two strings are anagramswrite a java program to check if two strings are anagram in java 3fanagram strings examplehow to check if two given string is the anagram of each otherjava function to check if two strings are anagramcheck if 2 stringsa re anagramsfind all anagrams in a string javatwo words are anagramscheck if anagram javajava strings anagramswap to check whether two strings are anagram of each other or not in javacheck whether two strings are anagramsanagram in java solutionanagram program for strings in javato check whether 2 strings are anagram or not in javacheck if two strings are anagrams of each otherare 2 string anagramstring are anagrams or not in javais annagram function javastring anagramsjava program to anagramcheck whether two strings are anagram of each otherjava program to check if two strings are anagrams of each otheranagrams of a string in javahow to find anagrams of in string in javahow to check for an anagramcheck whether two strings are anagram of each other jafunction for checking two integer aas anagramanagram with one letter different javaanagram of two strings in javablanagram in javacheck a string is anagram or notcheck s string is an anagram in javawrite a java program to check given two strings contain the same text or not in javawap to check whether two strings are anagram of each other or notfind anagrams in a string javajava program to check whether two strings are anagram stacoverflowhow to decide two strings are anagrams in javawrite a program to get two strings as input from the user the program should check if both the strings contains the same letters note 3a both the string values will be in lowercase check if word is anagram of another2 strings are anagramanagrams of a word javacompare two string anagrams program in java usong throwsanagram in java using 2 stringsfind whether 2 given strings are anagramsanagram of string in javajava anagram exampleblanagrams javahow to find anagrams of a string in javaanagrame java programmetwo string is anagram or notcheck if string is a anagramanagrams program in javahow do you check if two strings are anagrams of each other 3fanagram meaning in javaprogram to check whether two strings are anagrams or not in javajava check if two string anagramsanagrams code in javawrite a java program to check if the two strings are anagrams two string anagram javais 2 string anagram in javastring anagramtwo string being anagramscheck whether string is anagram or notgiven two strings 2c return true if they are anagrams of one anotherhow to check two strings are anagramanagram java solutionanagram java codecheck if string is anagramhow do you check if two strings are anagrams of each other 3f 28solution 29java anagrams codeprogram to check if two strings are anagrams in javahow to chwck the string is annagram or notanagram two string in javaanagram string in javatwo strings are anagrams if they are permutations of each otherwhat is anagram javacheck two string are anagram or notheck if two strings are anagrams in javacheck if he anagarams of one strings are in anotheris anagram javaa program to check anagram in javawap using java to check if two strings are anagrams of each otherjava anagrams3 write a program to check whether given to strings are anagramanagram or not or not in javahow to check if two string are anagramcheck if two strings are anagrams without using array java what is anagrams in javajava anagrams programanagrams stringhow to check if strings are anagramsanagram javacheck whether a given string is an anagram or notjava string anagramanagram sringamagram javaanagrams javaanagram in javaanagram example in javafind if two strings are anagramsanagram of a string in javaanagram problem in javahow to check if two strings are anagrams in javaanagram checker javacompare two strings and find if they are anagrams java write a simple anagram detector with arrays javaare the 2 strings anagramhow to compare anagram in a string in javahow to check if two strings are anagrams of each othercheck whether 2 strings are anagram of each otheranagram stringhow to know if two strings are anagrams in javacheck anagramwrite a program to find whether the given string is the anagram of the first string in javajava anagram codehow to check two strings are anagram of each othercheck whether substring string is anagram or notcheck two strings are anagrams in javaprogram to check whether two strings are anagramhow to find two strings are anagrams in javacheck if two string are anagramjava anagramfind whether 2 given strings are anagrams java program to check whether two strings are anagram or nottwo strings are anagrams or not in javacheck for anagram stringanagrams in java programjava program to check two strings are anagrams or notanagram of stringfind anagrams of a string javacheck if words are anagrams javaanagram program in javawhat is anagram stringfind two strings are anagramscheck whether the three strings are anagramjava program for anagramhow to check if two strings are anagrams of each other in javaanagram in a javacheck if two words are anagrams javafind the strings are anagrams 3ffind if strings are anagrams including spacescheck if strings are anagramshow to compare two string whether they are anagram or not 3fchecking two strings are anagrams of each otherhow to check anagram in javaanagram stringsfind anagram of a string in javajava check anagramgiven two words check if they are anagrams of each othercheck if 2 strings are anagrams javaanagram code in javacheck if two strings are anagrams javafind if strings are anagrams including spaescheck anagram in javahow to check if a word is anagram or notstring anagram in javaanagram checksanagram program in java using arraycheck if two strings are anagrams java quicklycheck if two strings are anagramstwo strings are anagramsif two strings are anagram13 write a function to check if two strings are anagrams or not 3fgiven two words 2c check if they are anagrams of each otherjava program to check if 2 strings are anagramsjava program to print anagramshow to check if two string are anagram in javahow to check whether two strings are anagrams in javahow to find two strings are anagrams in java