「Groovy」for in文でリストの要素を取得するサンプル
書式
for(変数名 in リスト名)
使用例
class Arkxample {
static void main(String[] args) {
// def リストの宣言
def cftLst = [11, 22, 'study', new Date(),'arkgame']
println("for in文でリストをループする")
for(item in cftLst){
println(item)
}
}
}
class Arkxample {
static void main(String[] args) {
// def リストの宣言
def cftLst = [11, 22, 'study', new Date(),'arkgame']
println("for in文でリストをループする")
for(item in cftLst){
println(item)
}
}
}
class Arkxample { static void main(String[] args) { // def リストの宣言 def cftLst = [11, 22, 'study', new Date(),'arkgame'] println("for in文でリストをループする") for(item in cftLst){ println(item) } } }
実行結果
for in文でリストをループする
11
22
study
Tue Aug 31 20:14:07 JST 2021
arkgame