For loop in Groovy

In this article let’s discuss about For loop groovy. Let’s go through the following methods without any delay 🙂

The for loop is generally used to iterate over a set of values.

For loop:
class Example{ 
   static void main(String[] args){
      for(int i = 0;i<5;i++) 
        {
         println(i);
       }	
  }
}
for-in loop :
class Example { 
   static void main(String[] args) { 
      int[] array = [0,1,2,3]; 	
      for(int i in array) { 
         println(i); 
      } 
   } 
}

Hope the above methods works for you. Happy Learning and get back to us Anytime.

Realted Posts : Julia run code