---
title: "Getting random numbers in java"  
description: "Getting random numbers in java"  
author: "Anonymous User"  
published: 2013-05-07  
updated: 2013-05-07  
canonical: https://www.mindstick.com/forum/831/getting-random-numbers-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Getting random numbers in java

Hello Guys,\
I would like to get a [random](https://www.mindstick.com/forum/33419/generating-random-numbers-in-objective-c) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) between 1 to 50.\
How may I do that with the help of Math.random(); in [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)?\
Is there any way to bound the [values](https://www.mindstick.com/forum/327/sum-textbox-values) that will be [accepted](https://yourviews.mindstick.com/view/80674/whatsapp-accepted-as-most-popular-app-worldwide)?\
Thank you

## Replies

### Reply by AVADHESH PATEL

Hi Jayprakash!\
Try as following\
Random rand = new Random();\
int n = rand.nextInt(50) + 1;\


---

Original Source: https://www.mindstick.com/forum/831/getting-random-numbers-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
