Groovy web console

subscribe to the feed Subscribe
to this
site

While_For

Published 1 month ago by Erik with tags loops
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def singers = ["Adele", "Barry Manilow", "Rhianna", "Tim McGraw", "Elton John"]
def i = 0
println ("Using a while loop:")

while (i < singers.size()) {  
println ("${singers[i++]}")
}

println ("")
println ("Using a for loop:")

for (String singer : singers) {  
println ("${singer}")
}