「Groovy」 for in文で配列の要素を抽出する

2021年8月31日

書式
for(変数名 in 配列名)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Arkmple {
static void main(String[] args) {
//配列
int[] cft = [40,51,62,63];
println "配列の要素"
//forループ
for(int ele in cft) {
println(ele);
}
}
}
class Arkmple { static void main(String[] args) { //配列 int[] cft = [40,51,62,63]; println "配列の要素" //forループ for(int ele in cft) { println(ele); } } }
class Arkmple {
   static void main(String[] args) {
   //配列
      int[] cft = [40,51,62,63];
      
      println "配列の要素"
      //forループ		
      for(int ele in cft) {
         println(ele);
      }
   } 
}

結果
配列の要素
40
51
62
63

Groovy

Posted by arkgame