Find error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
7th Feb 2022, 2:15 PM
Ashish Kumar
Ashish Kumar - avatar
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..
7th Feb 2022, 2:20 PM
Jayakrishna 🇮🇳
+ 2
Thanks
7th Feb 2022, 2:26 PM
Ashish Kumar
Ashish Kumar - avatar
+ 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 = "";
7th Feb 2022, 2:23 PM
saurabh
saurabh - avatar