Answers for "handle arrayindexoutofbound exception java"

0

arrayindexoutofboundsexception in java

public class ArrayIndexOutOfBoundException {  
  
    public static void main(String[] args) {  
		String[] arr = {"Mario","Giuseppe","Francesco","Alessandro"};   
		//Declaring 4 elements in the String array                                       
          
        for(int i=0;i<=arr.length;i++) {       
  
		//Here, no element is present at the iteration number arr.length, i.e 4  
            System.out.println(arr[i]);      
		//So it will throw ArrayIndexOutOfBoundException at iteration 4           
        }  
  
    }  
  
}
Posted by: Guest on September-10-2021

Code answers related to "handle arrayindexoutofbound exception java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language