IntelliJ IDEA:为什么readLine()需要两个用户输入而不是使用Kotlin? [英] IntelliJ IDEA: Why is readLine() expecting two user inputs instead of one using Kotlin?
问题描述
我编写了一个简单的程序,该程序从控制台获取用户的输入,然后将其打印出来.但是,当用户输入输入时,它会请求第二个用户输入,并且仅读取第二个输入.
I wrote a simple program that takes the user's input from the console and then prints it. But when the user enters the input, it requests a second user input and only reads the second input.
代码:
fun main(args: Array<String>) {
print("Enter text: ")
val stringInput = readLine()!!
println("Readed text: $stringInput")
}
控制台:
> Task :MainKt.main()
Enter text: FirstInput
SecondInput
Disconnected from the target VM, address: 'localhost:37282', transport: 'socket'
Connected to the target VM, address: '127.0.0.1:37264', transport: 'socket'
Readed text: SecondInput
我正在使用最新版本的IntelliJ IDEA.我不知道为什么会这样.我正在使用Windows.
I'm using the latest version of IntelliJ IDEA. I don't know why this is happening. I'm using Windows.
推荐答案
这似乎是IntelliJ内部控制台中的错误:请参见此票证(可通过此答案找到).
This seems to be a bug in IntelliJ's internal console: see this ticket (found via this answer).
(The same issue also appears to be behind this question and this question.)
我不知道它是否涉及相同的问题,但是此答案建议在编辑配置菜单,然后再次将其更改回.
I don't know if it refers to the same problem, but this answer recommends changing the JRE options in the Edit Configurations menu, and then changing them back again.
这篇关于IntelliJ IDEA:为什么readLine()需要两个用户输入而不是使用Kotlin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!