[英]What is the equivalent of Java Scanner in Kotlin?
什么是Kotlin中的Java Scanner ?
Scanner
我使用过readLine()但我想知道它的类型是否安全?
readLine()
你可以尝试这样的事情
val scan = Scanner(System.`in`) val n = scan.nextLine().trim().toInt()
因为“in”是Kotlin关键字
Kotlin重用了许多现有的Java库,使用Scanner完全可以。 否则, readLine只是使用System.in ,你可以在这里观察,这可能是一个简单的替代方案。
readLine
System.in
[英]what is the java equivalent of <?,?> in Kotlin?
[英]What is the Kotlin equivalent of this Java class
[英]what is the equivalent of this kotlin code to java
[英]What is the equivalent of Kotlin “by lazy” in Java?
[英]What is the java equivalent of this KOTLIN code?
[英]What is the equivalent of Java static methods in Kotlin?
[英]What is the equivalent of double colon (::) Java in Kotlin?
[英]What is the equivalent of readBigUInt64BE in java/kotlin?
[英]What is java equivalent of Kotlin's Function Types?
[英]What's the Kotlin equivalent of Java's String[]?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.