We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 33ab1ce commit 567e787Copy full SHA for 567e787
1 file changed
String Handling/stringPalindrome.java
@@ -7,16 +7,16 @@ public static void main(String[] args) {
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--)
+ for(int i=0,j=l-1;i<=j;i++,j--) //Traverse string from start and end
11
{
12
- if(s.charAt(i)!=s.charAt(j))
+ if(s.charAt(i)!=s.charAt(j)) //Check Each Character From start and end
13
14
- System.out.println("Not Palindrome");
+ System.out.println("Not Palindrome"); //if condition fails it displays not palindrome
15
temp=1;
16
break;
17
}
18
19
- if(temp==0)
+ if(temp==0) //if abpve condition does not satisfies then print palindrome
20
System.out.println("Palindrome");
21
22
0 commit comments