20 lines
413 B
Groovy
20 lines
413 B
Groovy
|
class Person{
|
||
|
def name
|
||
|
def age
|
||
|
|
||
|
def toString() {
|
||
|
"${name}, Alter: ${age}"
|
||
|
}
|
||
|
}
|
||
|
def personen = [new Person(name: "Alice", age: 20),
|
||
|
new Person(name: "Bob", age: 18),
|
||
|
new Person(name: "Charlie", age: 30),
|
||
|
new Person(name: "David", age: 15),
|
||
|
new Person(name: "Eve", age: 21)]
|
||
|
|
||
|
personen.each{println it}
|
||
|
def sum = 0
|
||
|
for (i in 1..10) {
|
||
|
sum += i
|
||
|
}
|
||
|
println("Summe der Zahlen von 1-10: ${sum}")
|