Inq*_*r21 0 arrays groovy input
我正在学习如何使用Groovy做一些noobie事情.我想知道如何将用户的输入读入一个字符串数组,这些字符串可以占用10个单词然后打印出来.
你可以这样做:
System.in.withReader {
print 'input: '
def userInput = it.readLine()
println userInput[0]
}
Run Code Online (Sandbox Code Playgroud)
这将从控制台读取输入并打印第一个字符.
| 归档时间: |
|
| 查看次数: |
1274 次 |
| 最近记录: |