How i read char from user at command line

As I read char from the user on the command line. I am familiar with readInt (). There is something like this for characters.

This is for the Stanford course. I take online as part of Stanford's technology throughout the summer, and I need to finish soon before the high school starts.


Is there a way that I can do this using the acm.util, acm.program acm.util or java.awt class, because all this is allowed for assignment.

+3
source share
2 answers
final DataInputStream dis = new DataInputStream(System.in);
final char c = dis.readChar();
+8
source

The java.util.Scanner class was pretty much built for this :), but, oddly enough, it remains a bit of a hidden secret that few people know about.

+6
source

Source: https://habr.com/ru/post/1716724/


All Articles