Write a program to check if two given String is Anagram of each other.

 /*

Write a program to check if two given String is Anagram of each other. 

Your function should return true if two Strings are Anagram, false 

otherwise. A string is said to be an anagram if it contains the same characters and same length, but in a 

different order, e.g. army and Mary 

are anagrams. You can ignore cases for this problem.

*/

import java.util.*;

class Twentytwo

{

    public static void main(String arg[])     

    {

        int a , b ;

        Boolean f=true;

        Scanner obj= new Scanner(System.in);

        System.out.print("Enter 1st String : ");

        String s1 = obj.nextLine();

        System.out.print("Enter 2nd String : ");

        String s2= obj.nextLine();

        if( s1.length() == s2.length())

        {

            for(int i=0;i<s1.length();i++)

            {

                for(int j=0;j<s1.length();j++)

                {

                    if(s1.charAt(i)==s2.charAt(j))

                    {

                        f=true;

                        break;

                    }

                    else

                    {

                        f=false;

                    }

                }

            }

        }

        else

        {

               f=false;

        }

        if(f)

        {

            System.out.println(s1 + " & " + s2 + " Both String Are Anagrams");

        }

        else

        {

           System.out.println(s1 + " & " + s2 + " Both String Are Not Anagrams");

        }

    }

}

More Information on our channel Programmer Community

please like , share and subscribe to get notifications of new videos....

To understand this program video will coming soon on our you tube channel



Comments

Popular posts from this blog

Design and Develop a java program to read marks of a student and print the total and average of marks using scanner class.

Write a Java program to convert seconds to hour, minute and seconds.

Write a Java program to print the ascii value of a given character.