Skip to content

Fix NegativeArraySizeException in MainActivity#210

Draft
cursor[bot] wants to merge 1 commit intomainfrom
negativearraysizeexception--5-l0x763
Draft

Fix NegativeArraySizeException in MainActivity#210
cursor[bot] wants to merge 1 commit intomainfrom
negativearraysizeexception--5-l0x763

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor bot commented Apr 3, 2026

Description

Fixed the NegativeArraySizeException that occurred when clicking the negative_index button in MainActivity.

Changes Made

  • Changed array initialization from new int[-5] to new int[5] in the button click listener at line 61
  • Updated comment from "Unhandled - NegativeArraySizeException" to "Fixed - NegativeArraySizeException"

Root Cause

The exception was caused by attempting to create an array with a negative size (-5), which is not permitted in Java and throws a NegativeArraySizeException.

Testing

The fix changes the hardcoded negative array size to a valid positive size (5), which will prevent the exception from being thrown when the button is clicked.

Fixes ANDROID-EB

Open in Web Open in Cursor 

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.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (814e302) to head (ec93812).

Files with missing lines Patch % Lines
...main/java/com/example/vu/android/MainActivity.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #210   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        864     864           
  Branches      65      65           
=====================================
  Misses       864     864           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant