Learn Groovy, the friendly scripting language for the JVM: printing, variables, input, decisions, loops, closures, lists and maps, ending with a small receipt program.
8 lessons, 16 exercises. Runs Groovy 6.0.
Not started
Hello, output
Print text with println, print and printf, write comments, and see how a Groovy script runs from top to bottom.
Values and variables
Declare variables with def or a type, meet Groovy's basic types, and make constants with final.
Reading input and arithmetic
Read lines from standard input, convert text to numbers, and calculate with Groovy's operators, including its exact decimal division.
Making decisions
Branch with if/else, the ternary operator and Groovy's powerful switch, using comparisons, boolean logic and Groovy truth.
Loops
Repeat work with for-in loops over ranges, classic for and while loops, Groovy's times and each, and stop early with break and continue.
Methods and closures
Write methods with parameters and return values, use default arguments and closures, and understand what a method can see in a script.
Lists and maps
Store many values in lists and maps, and transform them with Groovy's closure-based methods like each, collect, findAll and sum.
Strings and a small project
Slice, split, join and format strings with Groovy's string methods, then combine everything so far into a receipt printer.
Your progress is saved in this browser. Sign in to keep it on every device.