Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Here we list all the major differences between Java and Groovy.


Floating point number literals are BigDecimals by default. So when you type 3.14, Groovy won't create a double or a float, but will instead create a BigDecimal. This might lead people into believing that Groovy is slow for arithmetics! 

If you really want to use floats or doubles, be sure to either define such numeric variables with their float or double types, like in:

Code Block
double piDouble = 3.14
float piFloat = 3.14 

Or else, you can also use suffixes like:

Code Block
def piDouble = 3.14d
def piFloat = 3.14f 

Default imports

All these packages and classes are imported by default, i.e. you do not have to use an explicit import statement to use them: