# Part 1 Array 7-Solution-removeAt()

**URL:** <https://forum.codewithmosh.com/t/part-1-array-7-solution-removeat/7991>\
**Category:** Data Structures\
**Created:** [October 17, 2021, 7:07pm UTC](https://forum.codewithmosh.com/t/part-1-array-7-solution-removeat/7991 "2021-10-17T19:07:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lindaaa](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lindaaa](https://forum.codewithmosh.com/u/Lindaaa)\
**Post date:** [October 17, 2021, 7:07pm UTC](https://forum.codewithmosh.com/t/part-1-array-7-solution-removeat/7991/1 "2021-10-17T19:07:20Z")

</div>

Hi, when I run the removeAt() part code with 3 items in the array, I run into an ArrayIndexOutOfBoundsException, I think in the for loop of removeAt(), we should use i \< count-1, instead of i\<count, does this make sense?

---

<div class="post-metadata">

**Author:** ![singhvishesh394](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/singhvishesh394/32/3903_2.png) [@singhvishesh394](https://forum.codewithmosh.com/u/singhvishesh394)\
**Post date:** [June 6, 2022, 4:14am UTC](https://forum.codewithmosh.com/t/part-1-array-7-solution-removeat/7991/2 "2022-06-06T04:14:10Z")

</div>

Yes, as the count will become the length of the array (after each insert operation) & we are trying to reduce the length by 1 post the removeAt method, so the right solution is to use count -1 in the for loop.
