Chapter 2Groovy for Java Eyes

Since Groovy supports Java syntax and preserves the Java semantics, we can intermix Java style and Groovy style at will. In this chapter we’ll start on familiar ground and transition to a more Groovy style of coding. We’ll begin with tasks we’re used to doing in Java, and as we transition them to Groovy code we’ll see how the Groovy versions are more concise and expressive. At the end of this chapter, we’ll look at some “gotchas”—a few things that might catch us off guard if we aren’t expecting them.

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.