Introduction

Learn about Groovy and its syntax.

What is Groovy?

Groovy is an open-source, dynamic language built for the JVM with a Java-like syntax.

Groovy is very similar in syntax to Java, so it is generally easy for Java developers to learn (Java code is generally valid Groovy code). However, Groovy has many additional features and relaxed syntax rules: closures, dynamic typing, meta-programming (via metaClass), semicolons are optional, regexsupport, operator overloading, GStrings, and more. Groovy is interpreted at runtime. But in Groovy 2.0, the ability to compile to byte-code and enforce type-checking was added to the language.

Compact syntax

Groovy’s syntax can be made far more compact than Java. For example, the following code is in standard Java 5+:

Get hands-on with 1200+ tech skills courses.