Taking inputs

Most efficient way to input ints floats doubles and strings?

val in: Scanner = Scanner(System.in) doesnt work

1 Like

This question seems to target Java in general, not a Kotlin specific problem. At least Scanner works for me without System.in.

import java.util.Locale import java.util.Scanner

fun main(args: Array<String>) {

https://habrahabr.ru/company/JetBrains/blog/222693/ suggests that this should work:

val input = Scanner(System.`in`)
val T = input.nextInt()

Yes. in is a keyword and the compiler complains with "expecting property name or receiver type" and "expecting an element".

See https://stackoverflow.com/questions/41283393/reading-input-from-the-console-in-kotlin for more examples and tricks for parsing input from console and files in Kotlin.