Thursday, November 02, 2006

Groovy:Expression Example Codes

Below are few example codes for the Groovy Expressions.

1)-Use of Boolean expression
def x = false
return x


2)-Use of IF statement
def x= newValue
if (x <>
return true;
else
return false;


3)-Use of ArrayList
def myList=[10,20,30,40,50]
if(myList.get(2) == 30){
return false
}
else{
return true
}


4)-Use of HashMap
def myMap=[1:"A",2:"B", 3:"C"]
if(myMap[2] == null){
return false
}
else{
return true
}

http://groovy.codehaus.org/Tutorial+1+-+Getting+started

No comments: