Skip to content

Commit 567e787

Browse files
authored
Update stringPalindrome.java
1 parent 33ab1ce commit 567e787

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

String Handling/stringPalindrome.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ public static void main(String[] args) {
77
String s=sc.nextLine();
88
int l=s.length();
99
int temp=0;
10-
for(int i=0,j=l-1;i<=j;i++,j--)
10+
for(int i=0,j=l-1;i<=j;i++,j--) //Traverse string from start and end
1111
{
12-
if(s.charAt(i)!=s.charAt(j))
12+
if(s.charAt(i)!=s.charAt(j)) //Check Each Character From start and end
1313
{
14-
System.out.println("Not Palindrome");
14+
System.out.println("Not Palindrome"); //if condition fails it displays not palindrome
1515
temp=1;
1616
break;
1717
}
1818
}
19-
if(temp==0)
19+
if(temp==0) //if abpve condition does not satisfies then print palindrome
2020
System.out.println("Palindrome");
2121
}
2222
}

0 commit comments

Comments
 (0)