File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .io .*;
2+ import java .util .*;
3+ class Anagram {
4+ public static void main (String args []){
5+ String str1 ,str2 ;
6+ Scanner sc =new Scanner (System .in );
7+ System .out .println ("Enter the String 1" );
8+ str1 =sc .nextLine ();
9+ System .out .println ("Enter the String 2" );
10+ str2 =sc .nextLine ();
11+ if (str1 .length ()!=str2 .length ()){
12+ System .out .println ("The Strings " +str1 +" and" +str2 +" is not a Anagram" );
13+ }
14+ else {
15+ str1 =str1 .toLowerCase ();
16+ str2 =str2 .toLowerCase ();
17+ char []arr1 =str1 .toCharArray ();
18+ char []arr2 =str2 .toCharArray ();
19+ Arrays .sort (arr1 );
20+ Arrays .sort (arr2 );
21+ if (Arrays .equals (arr1 ,arr2 )==true ){
22+ System .out .println ("The Strings " +str1 +" and" +str2 +" is a Anagram" );
23+ }
24+ else {
25+ System .out .println ("The Strings " +str1 +" and" +sātr2 +" is not a Anagram" );
26+ }
27+ }
28+ }
29+ }
30+
31+
32+
You can’t perform that action at this time.
0 commit comments