My first Groovy program

To break the ice with a new programming language is always good to write code that displays a message on the screen.

 def x, y, date, message
 message = "Test message: "; x = 3; y = 5;
 date = new Date()
 println message + "Testing a Groovy class"
 println "The sum of ${x} + ${y} is ${x + y}"
 println "The date is " + date

This shows the following output on the console:

Test message: Testing a Groovy class
The sum of 3 + 5 is 8
The date is Mon Nov 29 21:21:54 CET 2010
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: