Introducing the Groovy language
In the following sections, we will cover some of the fundamental concepts and features of the Groovy language. A working knowledge of Java is assumed, so we will focus on what is different between the Groovy and Java languages.
The module structure
Groovy programs and scripts are generally stored in Groovy source files with the .groovy
extension. The exception to this are the Unix "shebang" scripts described in Chapter 2, Groovy Quick Start. Unlike Java source files, which must always contain a class definition, Groovy source files can contain both class definitions and inline scripting. When we compile or run a Groovy script, Groovy generates a class object for each Groovy class that it encounters in the source. If the source file contains some scripting elements, it also generates a class object for these.
To see how this works, let's take an example script and compile it with the Groovy compiler. We can use the GVM tool we encountered in Chapter...