Java Reference
In-Depth Information
constraints:BL.CENTER)
}
}
The resulting image is shown in figure 2.3 .
Figure 2.3. The “Hello, World” Swing user interface, holding the image returned by Google Chart
Lessons Learned (Google Chart)
1. Groovy variables can have types, or you can use the def keyword if you don't
know or don't care. The keyword def can also be used as a method return type or
argument.
2. Groovy has native syntax for lists and maps. This example used a Groovy map;
lists are used in many other examples throughout the topic.
3. Closures are like anonymous function bodies with parameters.
4. The collect method transforms a collection by applying a closure to each ele-
ment and returning the resulting list.
5. The Groovy JDK adds many methods to the standard Java API.
6. Groovy parsers and builders simplify working with many APIs.
The next example demonstrates Groovy's XML parsing and generation capabilities, data-
base manipulation, regular expressions, groovlets, and more.
 
Search WWH ::




Custom Search