Questions tagged [arrayindexoutofboundsexception]

41 questions
0
votes
1 answer

my app shows ArrayIndexOutOfBoundsException when calling it back from background

I'm trying to program a quiz app. My app crashes as soon as I run it in the background and then open it again. I get an ArrayIndexOutOfBoundsException. Unfortunately I cannot see the error although I can see the line in the Logcat. I created an…
-1
votes
1 answer

Can't find the source of ArrayIndexOutOfBoundsException

I know there have been other posts about ArrayIndexOutOfBoundsException, but I still can't pinpoint where this exception occurs. I've been working on this beast for entire week now. I am now blind to everything and therefore need a fresh set of…
-1
votes
1 answer

Checking adjacent cells in a java ArrayList for minesweeper

I have all my cells stored in an ArrayList and I want to check how many mines they are surrounded by (mines are cells with a not null mine png). I thought of checking the positions -1, +1, -9, +9, -10, +10, -11, +11 relative to each cell and add 1…
-2
votes
2 answers

Return keyword in void method not always working JAVA

I am coding with Java a function that checks if a date it's ok or not and want to jump up of the method if some condition is executed. I've read a similar question but hasn't the same trouble as it occurs in general and that's not what I want to…
DBG
  • 1
  • 1
-2
votes
1 answer

Where is the problem in code for which I am facing Array Index out of Bounds problem?

I am facing a problem in Merge Sort coded in Java language. Please can you see where I am wrong because I am facing Index out of bounds problem. I am sharing the code. Please check ! The error in the output box is : "Exception in thread "main"…
-2
votes
1 answer

How does Java handle an out-of-bound array index in a while-loop condition?

I'm following a tutorial for a two-pointer implementation (solution for 3Sum essentially) and I'm confused about the second while-loop in this search method: private static void searchPair(int[] arr, int targetSum, int left, List>…
-2
votes
1 answer

How to fix the following error java.lang.ArrayIndexOutOfBoundsException

I wanted to ask a question of code that has grated ja, I have the following code, I am going through a 10x5 array to fill it with number 1, to 49 for a primitive and the function that is responsible for making ticket gives me very rare errors. Index…
-3
votes
2 answers

ArrayIndexOutOfBound error when i used enhanced for loop

Can we use enhanced for loop without getting ArrayIndexOutOfBound error. because after using normal for loop it is working. public static void main(String[] args) { int a[] = {1,2,3,4}; int b[] = {1,2,3,4}; boolean status =…
-3
votes
3 answers

Why the count is not printing after for loop?

After each loop count and count1 are updated. After giving inputs in Scanner, I'm not getting any output. Scanner sc = new Scanner(System.in); int t = sc.nextInt(); // t=1 while (t != 0) { int n = sc.nextInt(); // n=5 int a[] = new int[n];…
1 2
3