This is the error i get..
Enter employee name: Bryan
Enter employee's salary: 123
Enter employee name: Mark
Enter employee's salary: 456
Enter employee name: Fajutag
Enter employee's salary: 789
Enter employee name: qwe
Enter employee's salary: 32
Enter employee name: qew
Enter employee's salary: 312
Enter employee name: qew
Enter employee's salary: 65
Enter employee name: qwe
Enter employee's salary: 654
Enter employee name: qwe
Enter employee's salary: 654
Enter employee name: qwe
Enter employee's salary: 654
Enter employee name: qwe
Enter employee's salary: 645

Number of employees with salaries of at least P 18,000 :0
Number of employees with salaries of below P 18,000 :10
Total salary paid to all the employees : P4384
java.lang.ArrayIndexOutOfBoundsException: 10
    at Salary.Employee(Salary.java:41)
    at Salary.main(Salary.java:85)
Exception in thread "main" 
Process completed.

What is the solution to this error 
java.lang.ArrayIndexOutOfBoundsException: 10
    at Salary.Employee(Salary.java:41)
    at Salary.main(Salary.java:85)
Exception in thread "main"

Edited 4 Years Ago by JamesCherrill: changed snippet to discussion

java.lang.ArrayIndexOutOfBoundsException: 10

the problem is: your array is declared as an array of 10 elements, which sets the valid index-range from 0 to 9, yet somewhere you are trying to access the element on index 10

try by resetting the value from ctr1. also, you may want to re-format the output you are generating.

System.out.println("Name of employees with salaries of at least P 18,000 :");
                System.out.print(name[ctr] + salary[ctr1]);

'll be a lot more clear if you print it like this:

System.out.println("Name of employees with salaries of at least P 18,000 : " + name[ctr] + salary[ctr1]);

java.lang.ArrayIndexOutOfBoundsException: 10
at Salary.Employee(Salary.java:41)

This also tells you the problem is on line 41 of Salary.java

This question has already been answered. Start a new discussion instead.