Skip to content
Hello, Groovy
step 1/5

Reading — step 1 of 5

Learn

~1 min readBasics

Groovy was created in 2003 by James Strachan as a dynamic language for the JVM. Most people meet it through Gradle build scripts or Jenkins pipelines — Groovy was chosen specifically because you can write a script as plain top-level statements, no class needed.

println "Hello, Groovy!"

That's a complete Groovy program. No class, no main, just statements. The Groovy compiler wraps your script in a hidden class for you.

Groovy is a Java superset — almost any valid Java is also valid Groovy. But idiomatic Groovy looks more like Python or Ruby:

def greet(name) {
    "Hello, $name!"     // string interpolation, implicit return
}

println greet("Ada")

def declares a variable or function with dynamic type. Groovy infers types where it can; def is when you don't care.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…