+ 1
Find error
Output is always same https://code.sololearn.com/cyAKnDQQHsV1/?ref=app
3 Answers
+ 3
You are assigning a space to reversed string by
String nstr=" "; so nstr have an extra space along with reversed input string..
Just use
String nstr="";
and then check again..
Hope it helps..
+ 2
Thanks
+ 1
String nstr=" ";// space is also a character
SO final string never equals original string
So just initialize with empty string like below
String nstr = "";