Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:00:46+00:00 2026-06-13T16:00:46+00:00

Platform: JCreator I usually use for loops that count from the back because theoretically

  • 0

Platform: JCreator

I usually use for loops that count from the back because theoretically when removing they should collapse fine:

0123456789

removing even numbers:

i = 9: 0123456789
i = 8 //remove 8: 012345679
i = 7: 012345679
i = 6 //remove 6: 01234579

and so on

But I get this exception when the object is removed:

Exception in thread “AWT-EventQueue-0” java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

for (int i = dArea.size() - 1; i >= 0; i--) {
    if (dArea.get(i).getOwn() == 1) {
        if (dArea.get(i).getSK() == 2) {
            if (dArea.get(i).getX() - dArea.get(i).getW() / 2 > 1350) {
                dArea.remove(i);
            }
            if (dArea.get(i).getX() + dArea.get(i).getW() / 2 < 0) {
                dArea.remove(i);
            }
            if (dArea.get(i).getY() - dArea.get(i).getH() / 2 > 685) {
                dArea.remove(i);
            }
            if (dArea.get(i).getY() + dArea.get(i).getH() / 2 < 0) {
                dArea.remove(i);
            }
        }
    }
}

Any ideas why and how to fix?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:00:47+00:00Added an answer on June 13, 2026 at 4:00 pm

    Try using else if instead of if.

    Otherwise one iteration in your loop may delete more than one element (once for the ‘w’ check and once for the ‘h’ check).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Platform: asp.net 4.0 I load scriptmanager from a baseclass for custom cdn handling and
I use the platform virb.com for my website and am having issues with getting
The platform i'm working with is DrScheme. I've seen that a pair (a b)
Platform: C# 2.0 WinForms I have a factory class that provides an instantiation of
The platform I am working on needs to dynamically load Javascript files that embed
This platform I'm working on uses some mechanics to determine if it should do
Platform is windows only. From Java I'd like to send input (key strokes and
im looking for cross platform GUI for free for commercial project ( that means
I am programming cross-platform apps via PhoneGap and I learned that using template engines
Possible Duplicate: Cross-platform, cross-browser way to play sound from Javascript? I am looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.