Java Reference
In-Depth Information
That's the whole program. In Java, you need a main method inside a class, and inside the
main method you call System.out.println to write to the console. Java developers
are used to it, but there are roughly 8 to 10 different object-oriented concepts involved, de-
pending on how you count them. [ 3 ] In Groovy, the whole program is a single line.
3 A rough count includes classes, methods, strings, arrays, public access, static methods and attributes, void return
types, overloaded methods like println , and more. It's no accident that Bruce Eckel's Thinking in Java (Prentice-
Hall, 2002) takes over 100 pages just to get to his first “Hello, World” program.
To demonstrate, consider one of the two execution environments that come with Groovy,
the groovysh command, which starts the Groovy shell. The Groovy shell is a REPL [ 4 ]
that allows you to execute Groovy code a line at a time. All of the lines in the following
listing produce the same result.
4 Read-Eval-Print Loop; see http://en.wikipedia.org/wiki/REPL for details.
Listing B.1. Running “Hello, World!” in the Groovy shell
 
 
Search WWH ::




Custom Search