Skip to content

Commit 7f67dc5

Browse files
committed
Java code to check string palindrome
1 parent 883e18c commit 7f67dc5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Palindrome/palindrome.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.util.*;
2+
class palindrome
3+
{
4+
public static void main()
5+
{
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Enter your word");
8+
String str = sc.nextLine();
9+
String s = str;
10+
String st = "";
11+
char ch;int i;
12+
for(i=0;i<str.length();i++)
13+
{
14+
ch = str.charAt(i);
15+
st = ch+st;
16+
}
17+
if(s.equalsIgnoreCase(st))
18+
System.out.println("Palindrome word");
19+
else
20+
System.out.println("Not a Palindrome word");
21+
}
22+
}
23+

0 commit comments

Comments
 (0)