Creating an object called obj of type java.util.ArrayList which implements the java.util.List interface.

instanceof checks if obj is the subclass of some class.

getClass returns the exact type of an object.

examples/groovy/check_type.groovy

def obj = ["question", 42, 'answer']

println obj.getClass()   // class java.util.ArrayList

println (obj instanceof List)                   // true
println (obj instanceof java.util.ArrayList)    // true

println (obj.getClass() == List)                // false
println (obj.getClass() == java.util.ArrayList) // true