nextInt(3) can be one of: 0, 1, 2.
nextInt(3) +1 then becomes one of: 1, 2, 3.
This:
imageArr[rndInt]
expects values 0, 1, 2
So, take out the "+1", to avoid getting an index-out-of-bounds exception.
-- Kostya
07.08.2011 0:01, Zwiebel пишет:
> Random rand = new Random();
> int rndInt = rand.nextInt(3) + 1;
--
Kostya Vasilyev
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment