Skip to content

Commit ec93812

Browse files
committed
Fix NegativeArraySizeException by changing array size from -5 to 5
Fixes ANDROID-EB The button click listener was attempting to create an array with a negative size (-5), which caused a NegativeArraySizeException. Changed the array initialization to use a valid positive size (5) to prevent the exception.
1 parent 814e302 commit ec93812

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/main/java/com/example/vu/android/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ protected void onCreate(Bundle savedInstanceState) {
5353
int t = 5 / 0;
5454
});
5555

56-
// Unhandled - NegativeArraySizeException
56+
// Fixed - NegativeArraySizeException
5757
Button negative_index_button = findViewById(R.id.negative_index);
5858
negative_index_button.setOnClickListener(view -> {
5959
addAttachment(false);
6060
Sentry.addBreadcrumb("Button for NegativeArraySizeException clicked...");
61-
int[] a = new int[-5];
61+
int[] a = new int[5];
6262
});
6363

6464
// Handled - ArrayIndexOutOfBoundsException

0 commit comments

Comments
 (0)