-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_Word.java
More file actions
41 lines (38 loc) · 1007 Bytes
/
Copy path03_Word.java
File metadata and controls
41 lines (38 loc) · 1007 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
import java.util.*;
class word
{
String pal(String n)
{
String b = "";
for(int i = n.length() -1;i>=0;i--)
{
b = b + n.charAt(i);
}
return b;
}
public static void main(String args[])
{
word b1 = new word();
ArrayList<String> a = new ArrayList<>(Arrays.asList("Ganesh","Babu","Tenet","Rotator","Malayalam","racecar"));
ArrayList<String> b = new ArrayList<>(Arrays.asList());
ArrayList<String> c = new ArrayList<>(Arrays.asList());
for(int i = 0;i<a.size();i++)
{
a.set(i,b1.pal(a.get(i)));
}
for(int i = 0;i<a.size();i++)
{
if(a.get(i).equalsIgnoreCase(b1.pal(a.get(i))))
{
b.add(b1.pal(a.get(i)));
}
else
{
c.add(b1.pal(a.get(i)));
}
}
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}