Search

Dark theme | Light theme

October 15, 2009

Groovy Goodness: Default Imports

Groovy allows to write dense code. For example we don't have to write explicit import statements for a lot of every day packages. The following packages are imported by default in Groovy:

java.io.* 
java.lang.* 
java.math.BigDecimal 
java.math.BigInteger 
java.net.* 
java.util.* 
groovy.lang.* 
groovy.util.* 

So we can write code like this without an import statement:

def now = new Date()
def file = new File(".")
def url = new URL('http://mrhaki.blogspot.com')
def list = new ArrayList()