+ 1

What's wrong with this code

I want to make it print each word reverse Example:sample input :I LOVE JAVA output :I EVOL AVAJ https://code.sololearn.com/c9DuMpa8XQiL/?ref=app

12th Dec 2018, 4:46 PM
Yash
Yash - avatar
6 Respostas
+ 2
In line 8 String n=sc.next()+' '; change to String n=sc.nextLine(); // Using next() will only return what comes before a space. nextLine() will return whole line
12th Dec 2018, 4:56 PM
Michal
Michal - avatar
+ 3
Good luck with learning then. I provided you my example so next time you can also think this way to solve another problem. // And of course I'm not saying that my example is better than yours. This is just other way to solve this problem.
12th Dec 2018, 5:21 PM
Michal
Michal - avatar
+ 2
Oh yeah! 😀 thx # Michal But what's different between. next () and nextLine() both can help in inputting string
12th Dec 2018, 4:59 PM
Yash
Yash - avatar
+ 2
I added difference in my first post. //And this is my example https://code.sololearn.com/cEsGE4DkML7T/?ref=app
12th Dec 2018, 5:11 PM
Michal
Michal - avatar
+ 2
Woop! It just went above my head, dude u belong to pro league whereas I use my basic knowledge about syntax in Java to form functioning codes as you can see I have tons of things left to learn In Java m just a beginner
12th Dec 2018, 5:17 PM
Yash
Yash - avatar
+ 2
Yeah just ended in few lines unlike mine😁 Anyway thx
12th Dec 2018, 5:23 PM
Yash
Yash - avatar