https://kotlinlang.org logo
#getting-started
Title
# getting-started
h

Hassaan

09/29/2022, 9:22 AM
can anybody tell me ‘scanner.nextInt( )’ equivalent in kotlin without using scanner class
k

Klitos Kyriacou

09/29/2022, 9:44 AM
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

Hassaan

09/29/2022, 9:50 AM
Regexes, map and what not I will stick to scanner class🤣
5 Views