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