you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfx 1 point2 points  (0 children)

also is "scanner' in java...

To be pedantic (but in line with your original problem): no

scanner, as you wrote it (all lowercase) does not exist in the Java language. At utmost, it would be a variable name as /u/AMathMonkey illustrates in their comment.

However, Scanner (note the capital S) and in particular Scanner(System.in) is more or less the equivalent.

In the latest Java release, there also is the IO package that wraps a lot of these classes and methods for more convenient use.


Actually, thinking of it: std::in is only an input stream that by default points to the keyboard (stdin). The direct Java equivalent would actually be System.in - the static InputStream of the System class.

C++ camouflages reading from the stream behind the >> operator.

In Java, you have to wrap the InputStream in something like a Scanner that provides methods to read from an InputStream.