Random Number on Command

Discussion in 'Plugin Development' started by deleted_91027365, Feb 27, 2015.

Thread Status:
Not open for further replies.
  1. Hey,

    how can i get a random number?
    I want to make a command that shows a random Number between 0 and 100.
    Is it possible?

    dunklesToast
     
  2. Offline

    adam753

    java.util.Random class
    Code:
    Random random = new Random();
    Code:
    int numberBetween0and100 = random.nextInt() % 101;
     
    tomudding likes this.
  3. Offline

    Epicballzy

  4. @adam753 That works! But i sometimes get numbers like -82 . How can I fix it?
     
  5. Offline

    adam753

    @dunklesToast
    If it's negative, make it not negative. Come on, I've spoonfed you enough as it is.
     
    The Fancy Whale likes this.
  6. Offline

    The Fancy Whale

    How are you getting negative numbers? xD What is the code you are using?
     
  7. Offline

    teej107

  8. Offline

    1Rogue

    Code:java
    1. int random = ThreadLocalRandom.current().nextInt(101);
     
Thread Status:
Not open for further replies.

Share This Page