42 questions
0
votes
1
answer
72
views
ArrayIndexOutOfBoundsException in AnyLogic Road Traffic Library - Index 3 out of bounds for length 3
I'm working on a road traffic simulation in AnyLogic where a set of vehicles randomly visit multiple stop lines and then proceed to their next destination. However, I'm encountering the following ...
0
votes
2
answers
92
views
why ArrayIndexOutOfBoundsException is occurring?
def change(amount: Int, coins: Array[Int]): Int = {
val dp = Array[Int](amount + 1)
dp(0) = 1
for {
coin <- coins
i <- coin to amount
} dp(...
1
vote
1
answer
219
views
ArrayList.remove() (removeAt() in Kotlin) causes weird IndexOutOfBoundsException
My code is simple but causes a weird IndexOutOfBoundsException.
It happens only once in ten thousands, but it happens. I can see them only in the Firebase Crashlytics Report.
Could you see the problem ...
-1
votes
1
answer
780
views
How to solve ArrayIndexOutOfBoundsException: Index 2048 out of bounds for length 2048 in AndroidStudio
I were working and building successfully each time.
Suddenly it's showing this message: Index 2048 out of bounds for length 2048
It shows only when I click to run on AVD. Beside this, during the build ...
0
votes
1
answer
54
views
A confusing exception out of bound error in java while solving a spiral 2d matrix question
I was solving this question, trying to generate spiral matrix but repeatedly getting error only when the length of the matrix is odd. It is working fine when the length is even
This is the code:
...
0
votes
0
answers
101
views
I have having Array Index Out Of Bound Error in this code [duplicate]
HERE IS THE JAVA CODE.HAVING ARRAY INDEX OUT OF BOUND ERROR ON RUNTIME.
i don't know what to do. I have tried every possible solution for this.
This is the error i am getting "Exception in thread ...
-2
votes
2
answers
162
views
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 ...
0
votes
2
answers
708
views
ArrayIndexOutOfBoundsException in assistedViewModel after upgrading
@Keep
@Composable
@InternalCoroutinesApi
@ExperimentalCoroutinesApi
fun SetupNavigationHost(
navController: NavHostController,
) {
NavHost(
navController = navController,
...
-1
votes
1
answer
46
views
Can't find the source of ArrayIndexOutOfBoundsException [duplicate]
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 ...
0
votes
0
answers
42
views
I have made a program in Java to accept and display a matrix but I am getting an ArrayIndexOutOfBoundsException [duplicate]
When I run the program, the accept method() runs smoothly but when I try to run the display() method, it shows an ArrayIndexOutOfBoundException: Index 0 out of bounds for length 0. I think it is ...
0
votes
1
answer
71
views
Is it possible to get the value of an ArrayIndexOutOfBoundsException in Java?
I'm trying to do a program which uses a matrix and makes a new one with each element being the sum of every adjacent element of the original one plus itself.
It's very easy to understand that the &...
-2
votes
1
answer
744
views
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 ...
1
vote
4
answers
158
views
Codingbat challenge: zeroFront Stream API Solution
Given the task zeroFront notAlone from CodingBat:
Return an array that contains the exact same numbers as the given
array, but rearranged so that all the zeros are grouped at the start
of the array.
...
0
votes
2
answers
2k
views
Unable to start activity: java.lang.ArrayIndexOutOfBoundsException
Everyone, hi!
Friends, when you click on the button, a new activity does not start. The following exception occurs: java.lang.ArrayIndexOutOfBoundsException.
The log of my error is presented below:
E/...
0
votes
0
answers
333
views
Out of bounds exception on array that has not been initialized to a specific size
C# Coding for unity
I have several arrays set as such.
public float[] arrayName;
no set number of elements anywhere in my code
I can access the arrays up to 6 no problems but when I get to 7 I get an ...
0
votes
2
answers
724
views
I am receiving an error: no exception of type ArrayIndexOutOfBoundsException can be thrown; an exception type must be a subtype of class Throwable
import java.util.*;
public class ArrayIndexOutOfBoundsException {
public static void main(String[] args) {
int[] array = new int[100];
//creating array with 100 storage spaces
for(int ...
-1
votes
1
answer
190
views
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,...
0
votes
2
answers
150
views
Index out of bound, java
I have a problem regarding index out of bound error in arrays.
I want to create a method that takes month and day as parameter and returns day of the year.If any of the parameters are incorrect, the ...
0
votes
1
answer
184
views
Append swing jbutton elements to array in java
I am working on a messaging application. The GUI is written in Java Swing. When the client starts, it asks my server for the chats a specific user is involved in. The server will send these in the ...
0
votes
1
answer
1k
views
Index out of bounds despite not being out of bounds?
I'm making a java program for schoolwork where you can add, move and remove stuff from containers. I have to use commands like "add 100" "remove 50". The stop command "lopeta&...
-3
votes
2
answers
89
views
ArrayIndexOutOfBound error when i used enhanced for loop [duplicate]
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};
...
0
votes
1
answer
96
views
i run the rmi program below but it shows command execution failed
This program should send a text message from client to the server. i finished compiled the file. the server.java runs successfully but the client.java shows error.
the error list is too long so i only ...
0
votes
1
answer
223
views
The Count of Remaining Arguments
I need to create a program that takes integer command-line arguments. The first argument would be the count of the remaining arguments that are between 1 and 100 (inclusive of 1 and 100). It then ...
0
votes
1
answer
464
views
App crashes on putting more than 28 'composable' element inside AnimatedNavHost (Jetpack Compose)
My app is a single activity app with different screens represented by composables. I am using navigation component to handle screen navigation.
My navigation component has AnimatedNavHost as:
...
0
votes
1
answer
297
views
ArrayIndexOutOfBoundsException when Creating LinearLayout
Hello? I am debugging some issue related with Android widget.
My app is using two thread provided by Glide library to make original widget image file and thumbnail widget image file.
When Making a ...
1
vote
1
answer
65
views
Randomized QuickSort IndexOutOfBounds exception [duplicate]
this is the QuickSort Randomized that I've come up with, but it constantly throws out IndexOutOfBounds exception. Could I have some help with it? Thanks!
import java.util.Random;
public class ...
0
votes
1
answer
261
views
Got ArrayIndexOutOfBoundException when not out of bound
I'm writing an implementation for AES with 128 bit key. An exception is thrown at the last line of the else block.
private static int KEY_SIZE_IN_BYTE = 16;
private static int ...
0
votes
1
answer
460
views
What is wrong with this binary search? IndexOutOfBounds [duplicate]
I'm trying to write the binary search algorithm, But Geeks for Geeks practice problem Binary Search yields following error:
Runtime Error:
Runtime ErrorException in thread "main" java.lang....
0
votes
1
answer
65
views
MAKING GAME BOARD: How do you shorten this code of creating array, and how do you print them out?
I'm working on a gameboard that prints out something like this:
Here's the code I wrote
void showBoard() {
String city1, city2, city3, city4, city5, city6, city7, city8, city9, city10;
...
-1
votes
1
answer
227
views
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,...
0
votes
2
answers
886
views
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 with RMI
I have three java files one is RMI server and RMI client and interface file, as follow:
server:
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.net.*;
public ...
0
votes
1
answer
808
views
Primefaces 10 dataTable p:dataExporter generate ArrayIndexOutOfBoundsException on render after migration
Environment:
Jboss 7.2
Primefaces 10
Java 11
I have migrated from primefaces 8 to primefaces 10 dataTable p:dataExporter generate ArrayIndexOutOfBoundsException on render the xhtml.
When I comment ...
1
vote
0
answers
1k
views
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
I am trying to implement dark theme from fragment named as "Fragment_One" in android studio.
This is from that fragment file
if (!isChecked) {
...
0
votes
2
answers
244
views
2D Array work, out of bounds error, for loop,
One of my school works tells us to make an 2D array, and display what is in the array. I don't know why it is saying out of bounds, and am kind of stuck. What we where tasked to do is to make, 10 ...
1
vote
1
answer
292
views
ArrayIndexOutOfBoundsException for Java Lambda
I am trying to convert my code to lambda version and I get java.lang.ArrayIndexOutOfBoundsException: 18 exception when I am building the code.
This is the working code:
private void run(){
...
-2
votes
1
answer
569
views
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 ...
0
votes
1
answer
136
views
"Hello world" exercise in c++ throws ArrayIndexOutOfBoundsException
My textbook showed this piece of C++ code to run however when I run it on net beans it displays this error Exception in thread "main" ArrayIndexOutOfBoundsException: 0
#include <iostream&...
0
votes
1
answer
1k
views
How to test ArrayIndexOutOfBoundsException?
I have never tested with JUnit, not sure what I have to do in this case
@Test(expected = ArrayIndexOutOfBoundsException.class)
public void throwsArrayIndexException() {
...
}
I just have to test ...
0
votes
1
answer
125
views
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 ...
0
votes
0
answers
477
views
java.lang.ArrayIndexOutOfBoundsException length=42; index=42 android.text.Layout$HorizontalMeasurementProvider.get(Layout.java:1416)
It feels like a bug in the system. How to solve this problem
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2600)
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
...
-3
votes
3
answers
263
views
Why the count is not printing after for loop? [closed]
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 = ...
363
votes
25
answers
1.1m
views
What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?
What does ArrayIndexOutOfBoundsException mean and how do I get rid of it?
Here is a code sample that triggers the exception:
String[] names = { "tom", "bob", "harry" };
for (int i = 0; i <= ...