can anybody tell me ‘scanner.nextInt( )’ equivalen...
# getting-started
h
can anybody tell me ‘scanner.nextInt( )’ equivalent in kotlin without using scanner class
k
If you want to read an Int on a line by itself, call
readln().toInt()
. However,
scanner.nextInt()
can read multiple ints on the same line. If you want to support that, it gets a little bit more complicated. You can start with
readln().split("\\s+".toRegex()).map(String::toInt)
(untested).
h
Regexes, map and what not I will stick to scanner class🤣