---
title: "How can I generate random number in specific range in Android?"  
description: "How can I generate random number in specific range in Android?"  
author: "Anonymous User"  
published: 2013-05-07  
updated: 2013-05-07  
canonical: https://www.mindstick.com/forum/833/how-can-i-generate-random-number-in-specific-range-in-android  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# How can I generate random number in specific range in Android?

Hello everyone,\
I want to [generate random](https://www.mindstick.com/forum/159580/how-to-generate-random-numbers-in-c-sharp) no. in a specific [range](https://www.mindstick.com/articles/23243/complete-troubleshooting-tips-for-belkin-n300-range-extender-setup) for use in my [android application](https://www.mindstick.com/forum/33405/how-to-get-the-build-version-number-of-your-android-application). (Ex. Range Between 65 to 80)\
I try as per below [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii), but it is not very use full. It also returns the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) greater then max. value(greater then 80).\
Random r=new Random();[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) i1=(r.nextInt(80) +65);[Anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) have idea How I can generate random number in between range.\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi John!\
Replace your line of code which have following below\
[Random](https://www.mindstick.com/forum/33419/generating-random-numbers-in-objective-c) r = new Random();int i1=r.nextInt(80-65) + 65;\
This gives a random integer between 65 (inclusive) and 80 (exclusive), one of 65,66,...,78,79.


---

Original Source: https://www.mindstick.com/forum/833/how-can-i-generate-random-number-in-specific-range-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
