Groovy Console read input

后端 未结 5 750
闹比i
闹比i 2021-02-01 05:27

I\'m just starting to learn Groovy and I am experimenting in GroovyConsole.

Is there a way I can read user input? I have tried the code below but I get an error.

5条回答
  •  忘了有多久
    2021-02-01 05:44

    def readln = javax.swing.JOptionPane.&showInputDialog
    def username = readln 'What is your name?'
    println "Hello $username."
    

提交回复
热议问题