Overrun1
0
Q:

for loop in java as long as array

for(i = 0; i < arrayName.length; i++{
  	//print statement will output current index's value
 	System.out.println(arrayName[i]); 
}
0
// Java program to iterate over an array 
// using for loop 
import java.io.*; 
class GFG { 
  
    public static void main(String args[]) throws IOException 
    { 
        int ar[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 
        int i, x; 
  
        // iterating over an array 
        for (i = 0; i < ar.length; i++) { 
  
            // accessing each element of array 
            x = ar[i]; 
            System.out.print(x + " "); 
        } 
    } 
} 
0
// Java program to iterate over an array 
// using for loop 
import java.io.*; 
class GFG { 
  
    public static void main(String args[]) throws IOException 
    { 
        int ar[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 
        int i, x; 
  
        // iterating over an array 
        for (i = 0; i < ar.length; i++) { 
  
            // accessing each element of array 
            x = ar[i]; 
            System.out.print(x + " "); 
        } 
    } 
} 
0

New to Communities?

Join the community