Answer the question
In order to leave comments, you need to log in
Java Scanner. How to read data?
Reverse
I need to make a Reverse class that reads numbers from stdin and prints them to stdout in reverse order. As input, the program receives integers separated by a space.
Input example:
1 3
3
How to correctly read these characters through Scanner?
Answer the question
In order to leave comments, you need to log in
If no arithmetic is required, then you can just read nextLine() and then get an array of substrings by splitting the string on spaces with split(), and then output them in reverse order.
If you still need numbers, you can read them using the nextInt() method, or take the resulting substrings and convert each to an integer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question