Our example program demonstrates the use of switch statements. Here’s the full source code.
Here’s how you can run the Groovy script:
Groovy scripts can be executed directly using the groovy command. Save the script in a file named SwitchExample.groovy and run the command shown above.
Now that we can run and build basic Groovy programs, let’s learn more about the language.