+ 2

Can anyone tell what is wrong in the code

I am trying to print if the string is a palindrome or not. https://code.sololearn.com/c4RkO0iwd67F/#java

2nd Dec 2017, 3:16 PM
Coder
Coder - avatar
7 Answers
+ 5
At the end of the for loop, s2 is a character and not the reversed string
2nd Dec 2017, 3:23 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 5
Here, I modified your code a little, added some comments in to explain my perspective, hope it help somehow :) https://code.sololearn.com/ctp3Xu2O3WSa/?ref=app
2nd Dec 2017, 4:51 PM
Ipang
+ 4
@Gordie, Done! and thanks for reminding me ;)
2nd Dec 2017, 5:54 PM
Ipang
+ 2
Got the code corrected..Thanku all
2nd Dec 2017, 6:07 PM
Coder
Coder - avatar
+ 1
you need to get rid of the extra curly braces. also seems u are doing operation on the same string that u are using for comparison. keep ur S1 string unchanged and use the char arry or temp string. please try to print ur S1 string before you do comparison in ur current code. this might give you an idea if you have done anything wrong with ur S1. using copy.char[] is not going to help either. look at the code here, this might give u some insights. https://code.sololearn.com/cmhk7V5crzko/?ref=app
2nd Dec 2017, 5:56 PM
KeenCodr