We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 084a81a + 4c91054 commit f202d63Copy full SHA for f202d63
1 file changed
String Handling/stringPalindrome.java
@@ -0,0 +1,23 @@
1
+//Created a program to check whether given string is palindrome or not.
2
+import java.util.*;
3
+public class Main
4
+{
5
+ public static void main(String[] args) {
6
+ Scanner sc=new Scanner(System.in);
7
+ System.out.println("Enter a String");
8
+ String s=sc.nextLine();
9
+ int l=s.length();
10
+ int temp=0;
11
+ for(int i=0,j=l-1;i<=j;i++,j--) //Traverse string from start and end
12
+ {
13
+ if(s.charAt(i)!=s.charAt(j)) //Check Each Character From start and end
14
15
+ System.out.println("Not Palindrome"); //if condition fails it displays not palindrome
16
+ temp=1;
17
+ break;
18
+ }
19
20
+ if(temp==0) //if abpve condition does not satisfies then print palindrome
21
+ System.out.println("Palindrome");
22
23
+}
0 commit comments