[英]What is the equivalent of Java Scanner in Kotlin?
What is the equivalent of Java Scanner
in Kotlin? 什么是Kotlin中的Java Scanner
?
I have used readLine()
but I'd like to know whether it's type safe or not? 我使用过readLine()
但我想知道它的类型是否安全?
You can try something like this 你可以尝试这样的事情
val scan = Scanner(System.`in`)
val n = scan.nextLine().trim().toInt()
Since "in" is a Kotlin keyword 因为“in”是Kotlin关键字
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.