[英]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.