Hi, how about this: public int getMyNumber() {
int min = 1; int max = 8; Random r = new Random(); int i = r.nextInt(max - min + 1) + min switch(i) { case >= 5 && < 8: return getMyNumber() default: return i; } } Sorry I'm not at the position to try this out at the moment Am Donnerstag, 30. August 2012 12:16:02 UTC+2 schrieb thejaswi s: > > 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. Am Donnerstag, 30. August 2012 12:16:02 UTC+2 schrieb thejaswi s: > > 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en