[Solved] Output for reversing a string does not come as expected
For approach 1, all you need to do is remove the call to sc.nextLine() and everything will be fine. That’s because each line contains a “token” i.e. a word, delimited by whitespace. That’s what sc.next() will return. No need to call nextLine() after that. For your approach 2, you should carefully read the API documentation … Read more