简体   繁体   中英

Accepting User Input in Java

是否有可能使用某些库或任何东西在Java中添加类似输入的C ++(即不使用扫描仪或任何东西;只是简单的单个语句输入,如“cin >>”)?

No. It's not that easy because Java does not support operator overload

you can create a Scanner object

Scanner scan = new Scanner(System.in);

and read the user input with

String s = scan.readLine();

简单地说......不。使用扫描仪:

您不能让操作员重载并且Scanner在标准库中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM