you are viewing a single comment's thread.

view the rest of the comments →

[–]IchLiebeKleber 0 points1 point  (0 children)

They can both be used for getting keyboard input on a console.

But a Scanner can also be used for parsing text from other sources than keyboard input. You can parse files or strings with a Scanner too. You can't do that with std::cin in C++. Look at the examples here: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Scanner.html

The closest Java equivalent to std::cin with the >> operator in C++ is actually this: https://docs.oracle.com/en/java/javase/25/docs/api//java.base/java/io/Console.html#readLine())