-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstrpallin.java
40 lines (35 loc) · 897 Bytes
/
strpallin.java
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
import java.util.*;
import java.io.*;
class stringpalin
{
public static void main(String[] args)
{
String a,b="";
char c;
int d=0,i;
try
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string:");
a=sc.next();
d=a.length();
for(i=d-1;i>=0;i--)
{
b=b+a.charAt(i);
}
System.out.println("The Reverse of the string is:"+ b);
if(a.equals(b))
{
System.out.println("The string is Palindrome");
}
else
{
System.out.println("The string is not a palindrome");
}
}
catch(Exception e)
{
System.out.println("Enter only string");
}
}
}