i went over this code several time and i really cant understand why am getting the Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at qrt2.practice.main(practice.java:34) am using Eclips standard SDK
and the code is :
package qrt2; import javax.swing.*; public class practice { public static void main(String[] args) { //creating JOption for the input String num1 = JOptionPane.showInputDialog("Enter the first number"); int x = Integer.parseInt(num1); String num2 = JOptionPane.showInputDialog("Enter the first number"); int y = Integer.parseInt(num2); String num3 = JOptionPane.showInputDialog("Enter the first number"); int z = Integer.parseInt(num3); String num4 = JOptionPane.showInputDialog("Enter the first number"); int v = Integer.parseInt(num4); String num5 = JOptionPane.showInputDialog("Enter the first number"); int h = Integer.parseInt(num5); String num6 = JOptionPane.showInputDialog("Enter the first number"); int k = Integer.parseInt(num6); //creating array int [] ary = new int []{x,y,z,v,h,k}; int counter; for( counter=0;counter<ary.length;counter++); System.out.println(counter + " " + ary[counter]); } }