Groovy comes with a large library of classes that can be used to make the life of a developer easier. Some offer new features; the others are wrappers around existing Java Class Library classes to make them easier to use or enhance their functionalities. In this section, we will be looking at some important classes and types of Groovy's runtime library, sometimes called the Groovy Development Kit (GDK), which is installed as part of your Groovy installation.
Groovy offers its own variant of the java.lang.String
class: groovy.lang.GString
. Whenever you create a string with double quotes, Groovy looks whether a feature of GString
is used. If that's the case, then it creates a GString
; otherwise, it creates an ordinary java.lang.String
instance:
def s = "this is an ordinary java.lang.String instance";
The preceding string does not make use of Groovy features, so Groovy creates a normal java.lang.String
. One of the most useful features of...