20 lines
373 B
Groovy
20 lines
373 B
Groovy
def myList = [1,2,3,4,5,6,7,8,9,10]
|
|
def emptyList = []
|
|
|
|
def check(List<Integer> list) {
|
|
def counter = 0
|
|
|
|
if (list.size() == 0) {
|
|
return "Die übergebene Liste ist leer!"
|
|
}
|
|
for(int i = 0; i < list.size(); i++) {
|
|
if(list[i] % 2 == 0) {
|
|
counter++
|
|
}
|
|
}
|
|
return counter
|
|
}
|
|
|
|
println check(myList)
|
|
println check(emptyList)
|