forked from Ashutoshak5384/html-basic-web-page
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringpalindrom.java
More file actions
26 lines (26 loc) · 816 Bytes
/
Stringpalindrom.java
File metadata and controls
26 lines (26 loc) · 816 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
/* String Palindrom checking by comparing both ends */
import java.util.Scanner;
class StringPalindrom1
{
public static void main(String args[])
{
String str;
int n,i,j,flag=1;
Scanner sc=new Scanner(System.in);
System.out.println("Enter any String:");
str=sc.next();
n=str.length();
for(i=0,j=n-1;i<j;i++,j--)
{
if(str.charAt(i)!=str.charAt(j))
{
flag=0;
break;
}
}
if(flag==1)
System.out.println(str+" is Palindrom");
else
System.out.println(str+" is not Palindrom");
}
}