Hi, how about this:Why in the world would you use recursion to solve this simple problem... Not only that, but theoretically (probably not in practice) you could end up in an infinite or a really long recursion loop...public int getMyNumber(){int min = 1;
int max = 8;int i = r.nextInt(max - min + 1) + min
Random r = new Random();
switch(i)
{
case >= 5 && < 8: return getMyNumber()
default: return i;
}
Bob's way was much nicer and cleaner.
Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware
On Thu, Aug 30, 2012 at 4:40 AM, AntiBit <antonio.bitounis@gmail.com> wrote:
Hi, how about this:public int getMyNumber(){int min = 1;
int max = 8;int i = r.nextInt(max - min + 1) + min
Random r = new Random();
switch(i)
{
case >= 5 && < 8: return getMyNumber()
default: return i;
}
--
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