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

  • Home
  • SEARCH
  • 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 3238478
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:51:30+00:00 2026-05-17T17:51:30+00:00

I seem to be getting an array out of bounds exception but the problem

  • 0

I seem to be getting an array out of bounds exception but the problem is the error message and my System.out and eclipse’s debug tools tell me conflicting information.

This is my exception:

Exception in thread “main”
java.lang.IndexOutOfBoundsException:
Index: 9, Size: 9
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at InduceC45.C45(InduceC45.java:61)
at InduceC45.main(InduceC45.java:15)

Line 61 in InduceC45 is:

for(int attLoop = 1; attLoop <= attributes.get(splitAtt); attLoop++){

It’s saying that splitAtt is out of bounds for ArrayList attributes, simple enough.

So I tried using the debugger and I also tried putting some System.out’s to try to figure out what was going on, they basically gave me the same info, so here is the System.out’s

System.out.println("splitAtt="+splitAtt);
System.out.println("attributes="+attributes);
System.out.println("attributes="+attributes.get(splitAtt));

This the print outs resulted in this:

splitAtt=9
attributes=[3, 3, 3, 2,
3, 6, 3, 4, 4, 2]
attributes=2

I really don’t understand why I can reference it and not get an error if it’s not in the loop. I don’t think I’m doing anything tricky, let me know if anyone can think of a possible cause.

In case anyone wants the full source…
http://github.com/Ryuho/CSC466/blob/master/lab3/src/InduceC45.java Line 61

  • 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-05-17T17:51:30+00:00Added an answer on May 17, 2026 at 5:51 pm

    Inside of the loop, you remove an item from the list:

    attributes.remove(splitAtt); // Line 75
    

    On the second go around, the call to attributes.get(splitAtt) will then reference an index no longer in the list. Since you haven’t removed that last element before you enter the loop, your print statements succeed.

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

Sidebar

Related Questions

I seem to be getting a strange error when I run my tests in
I seem to be getting breakpoints from other programmers when checking out code... Where
I seem to be getting a type mismatch error when trying to do something
I am getting very frustrated because I cannot seem to figure out why Collections
In one of our application im getting an exception that i can not seem
I must be getting daft, but I can't seem to find how to read
I keep getting this NPE in my application and I can't seem to get
I'm getting confused with the include/exclude jargon, and my actual SVN client doesn't seem
I'm still getting used to the sizers in wxWidgets, and as such can't seem
I keep getting the following exception with a new resource Im making and i

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.