Thursday, August 30, 2012

[android-developers] Re: How to generate random numbers between 1 to 8?

        Random r = new Random();

        int randnum = r.nextInt(5)+1;

        if (randnum==5) randnum=8;


On Thursday, August 30, 2012 5:16:02 AM UTC-5, thejaswi s wrote:
In my application I want to generate random number between 1 to 8 and there should not be 5,6 and 7. i.e. random numbers must be (1, 2, 3, 4, 8). Thanks.

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate