Skip to content

Commit 33ab1ce

Browse files
committed
Palindrome
1 parent 4986f7c commit 33ab1ce

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
public class Main
3+
{
4+
public static void main(String[] args) {
5+
Scanner sc=new Scanner(System.in);
6+
System.out.println("Enter a String");
7+
String s=sc.nextLine();
8+
int l=s.length();
9+
int temp=0;
10+
for(int i=0,j=l-1;i<=j;i++,j--)
11+
{
12+
if(s.charAt(i)!=s.charAt(j))
13+
{
14+
System.out.println("Not Palindrome");
15+
temp=1;
16+
break;
17+
}
18+
}
19+
if(temp==0)
20+
System.out.println("Palindrome");
21+
}
22+
}

0 commit comments

Comments
 (0)