Random String from Stringlist

Discussion in 'Plugin Development' started by Uniclaw, Jan 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Uniclaw

    Hi!

    I've tryed to get a random string from a stringlist with this:
    [coe]
    int r = new Random().nextInt(m.size());
    String dm = m.get(r);
    [/code]

    Works perfectly, if there are more than 2 obejcts in the list - But if there are just two object, every time i get just the 1thst, and not the second!
     
  2. Offline

    DarkBladee12

    Uniclaw I don't think that that would choose the first every time... When there are just 2 objects there are not that much possibilities and often it is the same object. Just let the system print out the random number for 100 times or more and you will see ;)
     
  3. Offline

    Uniclaw

Thread Status:
Not open for further replies.

Share This Page