java program to find the given string is anagram or not using scanner.
Answers
Answered by
0
Answer:
Check if Two Strings Are Anagram using Array
String s1 = scanner. nextLine(); String s2 = scanner. nextLine();
s1 = s1. replaceAll(“\\s”, “”); s2 = s2. ...
char[] arr1 = s1. toLowerCase(). toCharArray(); ...
String s1 = scanner. nextLine(); String s2 = scanner. ...
s1 = s1. replaceAll(“\\s”, “”). toLowerCase();
Answered by
0
Answer:
import java.util.*;
class Anagram
{
static boolean isAnagram(String s , String s1)
{
char[] c = s.toCharArray();
char[] c1 = s1.toCharArray();
Arrays.sort(c);
Arrays.sort(c1);
return Arrays.equals(c,c1);
}
public static void main(String[] args)
{
System.out.println(isAnagram("man" , "amn"));
}
}
Explanation:
Similar questions