Java Program to determine whether two strings are the anagramTwo Strings are called the anagram if they contain the same characters. However, the order or sequence of the characters can be different. In this program, our task is to check for two strings that, they are the anagram or not. For this purpose, we are following a simpler approach. First of all, Compare the length of the strings, if they are not equal in the length then print the error message and make an exit, otherwise, convert the string into lower-case for the easy comparisons. Sort both the strings using bubble sort or other sorting methods. If the strings are found to be identical after sorting, then print that strings are anagram otherwise print that strings are not the anagram. For programming, follow the algorithm given below: Algorithm
Program:Output: Both the strings are anagram Next TopicJava Programs |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India