-
Sorting Strings
Create a list of strings. Sort them alphabetically. Sort them by length. Sort them by length in descending order.
Advanced: Sort by length, then sort equal length strings alphabetically
-
Processing a list of numbers
Create a list of numbers. Add them together. First double each number, then add them up. Compute their average.
-
Reading a web page
Using the Groovy JDK, access your home page and display the source code. Print the length of each line of the home page.
-
Closures as a filter
Create a list of numbers. Print all elements greater than zero.
-
Multi-line strings
Make a multi-line string. Compute the number of vowels on each line.
-
Padded binary output
Print the numbers from 0 to 15 in binary (use Java's
Integer.toBinaryString()
method). Use a method in String from the Groovy JDK to make all the output values have four digits.