Exercise 66

363 views
Skip to first unread message

dfernan...@gmail.com

unread,
Oct 26, 2014, 2:06:03 AM10/26/14
to moo...@googlegroups.com
Hi,

I'm having problems with week 3 exercise 66.

I am having a difficult time understanding how to compare Integers that are in a arraylist using just a for loop. I used what I know to answer the problem correctly. My code answers the exercises question but fails me by throwing  these two errors.

IndexOutOfBoundsException: Index: 1, Size: 1

IndexOutOfBoundsException: Index: 3, Size: 3



Best regards
___________


Please use our build in TMC Pastebin when asking questions related to your code 

In NetBeans, select TMC -> Send code to TMC pastebin. Copy the link you receive and paste it to your message.  

You may use our web interface to share code snippets: http://paste.mooc.fi

Joni Salmi

unread,
Oct 27, 2014, 10:41:41 AM10/27/14
to moo...@googlegroups.com
Hi,

You should use a loop. I have just updated tests to give more pleasant output.

As a hint "greatestSoFar".

Best regards
Joni

Dee

unread,
Oct 27, 2014, 11:03:59 AM10/27/14
to moo...@googlegroups.com
Hey, thanks for your reply.

Last night I FINALLY got it together and revamped my code and incorporated a for and while loops properly to keep track of the biggest number so far.  I found myself overthinking the logic process to account for the biggest number.

Because I used the math class, it will not pass the 2nd test because it doesn't read negative numbers. So at this time I am working to adjust my loop to account for negative numbers.





Reply all
Reply to author
Forward
0 new messages