The Groovy language is designed in a way that it fully supports the Java syntax (there are only few minor exceptions; for example,
do..while is not supported in Groovy). Most of the code that you can write in Java can automatically be considered Groovy code as well.
In this recipe, we will learn how simple it is to use existing Java classes and libraries from your Groovy code and we will explore some basic language features that makes Groovy—groovy!
This recipe has a rather simple setup. You can either start up the
groovyConsole, as described in the Starting groovyConsole to execute Groovy snippets recipe in Chapter 1, Getting Started with Groovy, or you can create a new file with the
*.groovy extension. ...