Annon means two words having same characters and
same length.
Same characters means both words made of a common
set of characters.
i.e teacher and cheater both words have same length
and same set of characters, so we can say such types of string or word as Annon
String or Annon word.
For more details see below written code to check that two string are Anon or not.
public void
testAnnon()
{
String str1="teacher";
String str2="cheater";
char[]ch1=str1.toCharArray();
char[]
ch2=str2.toCharArray();
Arrays.sort(ch1);
Arrays.sort(ch2);
boolean flag=Arrays.equals(ch1, ch2);
if(flag)
{
System.out.println("Given
strings are annon");
}
else
{
System.out.println("Given
strings are not annon");
}
}
No comments:
Post a Comment