java program to check the Anagram of the string where Case of the character matter.
import java.util.*;
public class HelloWorld {
public static void main(String[] args) {
String str1="Brijesh Kumarh";
String str2="Kumar Brijeshh";
char ch1[]=str1.toCharArray();
char ch2[]=str2.toCharArray();
Map<Character,Integer> map1=new HashMap<Character,Integer>();
Map<Character,Integer> map2=new HashMap<Character,Integer>();
for(Character ch:ch1)
{
if(map1.containsKey(ch))
{
map1.put(ch,map1.get(ch)+1);
}
else
{
map1.put(ch,1);
}
}
for(Character chh:ch2)
{
if(map2.containsKey(chh))
{
map2.put(chh,map2.get(chh)+1);
}
else
{
map2.put(chh,1);
}
}
if(map1.entrySet().containsAll(map2.entrySet()))
{
System.out.print("yes");
}
else
{
System.out.print("no");
}
}
}