user6457851
user6457851

Reputation:

Groovy error for simple program "unexpected token"

Could anyone please explain the following error? Many thanks :)

Joe-iMac-2:Desktop joe$ groovy ExampleTest.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/Users/joe/Desktop/ExampleTest.groovy: 2: unexpected token: in @ line 2, column 19.
   print “Please key in a word: “
                 ^

1 error

My code is this:

String str
print “Please key in a word: “
str = System.console().readLine()
println “The word was: “ + str
print “Now please key in another: “
str = System.console().readLine()
print = “And this one was: “ + str

Upvotes: 2

Views: 12305

Answers (1)

Óscar López
Óscar López

Reputation: 235984

It seems that the double quotes are wrong, try this:

print "Please key in a word: "

Replace all the quotes in your program with the right ones. Maybe you copied the code from a text with the wrong font?

Upvotes: 3

Related Questions