# Solved Random number

Discussion in 'Plugin Development' started by NickDEV, Sep 15, 2015.

Not open for further replies.
1. Offline

### NickDEV

How to generate a random number from 0 to 15? (I would like to use that random generated number as int number)

#1
2. Offline

### BrickBoy55

@NickDEV
Create a random with 15 as the constructor, then do:
Code:
```int number = <your random>.nextInt() + 1;
```

#2
3. Offline

#3
4. Offline

### BrickBoy55

@NickDEV What you would name your random variable.

#4
5. Offline

### NickDEV

@BrickBoy55 I don't know how to get a random number...

#5
6. Offline

### Hawktasard

@NickDEV
You can do something like this:
Code:java
`double myNumber = Math.random() * 15;`

edit: You should probably use Random though:
Code:java
`Random random = new Random();int num = random.nextInt(150);`

#6
7. Offline

### BrickBoy55

@NickDEV You'd do something like this:
Code:
```Random random = new Random(15); //Creating a new random variable with the name random, that holds can go up to 14.
int number = random.nextInt() + 1; // Making the random generate a random number. Adding 1 will make it so it is possible to get 15 as a number.```

#7
NickDEV likes this.
8. Offline

#8
9. Offline

#9