• Register
0 votes
103 views

Problem :

I am a beginner to Java programming. While executing my program i got below error
exception in thread "main" java.lang.arrayindexoutofboundsexception: 10
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

The problem is you have 50 students in your class and you want to view the value of the 51st student

if you make this int i[4] then i takes values i[0] i[1] i[2] i[3]

ftp resolve your problem you can try bellow code sample

double[] array = new double[50];

    for (int j = 0; j < 24; j++) {

    }

    for (int k = 25;  < 50; k++) {

    }
9 7 4
38,600 points

Related questions

1 vote
1 answer 22 views
22 views
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. &ldquo;Exception in thread "main" java.lang.arrayindexoutofboundsexception:&rdquo; I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 23 views
23 views
Problem: I am a beginner to programming. I'm a few weeks into my first programming class, so please bear with me. I am not a person to ask for help, so I have searched for an answer extensively with no luck. This is also my first time posting ... correct for future posts. This is what I got while running the program. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:50 on line 23
asked Feb 20 Ali 6.2k points
0 votes
1 answer 10 views
10 views
Problem: public class dereks { public static void main (String [] args){ int array [] = {1,2,3,5,6,7}; int sum =0; for(int counter=0; counter<=array.length; counter++){ sum+=array[counter]; } System.out.println(sum); } } Can anyone tell ... I can't understand why I'm getting the error message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at dereks.main(dereks.java:7)" .
asked Feb 20 Ali 6.2k points
0 votes
1 answer 17 views
17 views
Prblem: The error ArrayIndexOutOfBoundsException: 1 means index 1 is invalid and it's out of bounding i.e. more than the length of the array. Since the array has a zero-based index in Java, this means you are trying to access the second element of an array which only contains one element.
asked Feb 19 Ali 6.2k points
0 votes
1 answer 5 views
5 views
Problem: I am a beginner to programming. I'm a few weeks into my first programming class, so please bear with me. I am not a person to ask for help, so I have searched for an answer extensively with no luck. This is also my first time posting anything in any type of forum, so if my question structure is off I'm sorry and I will correct for future posts.
asked Feb 18 Ali 6.2k points
0 votes
1 answer 13 views
0 votes
1 answer 32 views
0 votes
1 answer 11 views
11 views
Thank you in advance for any help?
asked Jan 5 TeamScript 13.5k points
0 votes
1 answer 46 views
46 views
Problem : Currently I am learning Java. I have written code in Java but it gives me below error &ldquo;Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Minesweeper.main(Minesweeper.java:5)&rdquo;. I am unable to understand above error. How can I fix above error.
asked Feb 22, 2020 mphil 2.3k points
0 votes
1 answer 22 views
22 views
I wrote some code in java: public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter size of array:"); int size = sc.nextInt(); int[] intArray = new int[size]; for ( ... .journaldev.exceptions.ArrayIndexOutOfBoundsExceptionExample.main(ArrayIndexOutOfBoundsExceptionExample.java:23) What is the problem in my code and why am I getting this kind of error?
asked Mar 14, 2020 LizzyM 6.1k points