-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnagrams.java
More file actions
48 lines (32 loc) · 899 Bytes
/
Anagrams.java
File metadata and controls
48 lines (32 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package Collections1;
import java.util.Arrays;
public class Anagrams {
public static void main(String[] args) {
// TODO Auto-generated method stub
String var1 = "Ravishankar";
String var2 = "ShankarRavi";
char[] c1 = var1.toUpperCase().toCharArray();
char[] c2 = var2.toUpperCase().toCharArray();
Arrays.sort(c1);
Arrays.sort(c2);
if (Arrays.equals(c1, c2))
{
System.out.println("it is anagram");
}
else
System.out.println("not anagram");
String sb = "Malayalam12";
int len = sb.length();
String r = " ";
for (int j=len-1;j>=0;j--)
{
r = r + sb.charAt(j);
}
System.out.println("r : " + r);
if (sb.equals(r))
System.out.println("it is palindrome");
else
System.out.println("its not a palindrome);
}
}
/* testing the file for what was saud earurlinweb */