get integer number based Random String - Android java.util

Android examples for java.util:Random String

Description

get integer number based Random String

Demo Code

import java.util.Random;

public class Main {

  public static String getRandomStr(int num) {
    StringBuffer temp = new StringBuffer();
    Random rand = new Random();
    for (int i = 0; i < num; i++) {
      temp.append(rand.nextInt(10));/*from   www  .  j  a v  a 2  s . c om*/
    }
    return temp.toString();
  }

}

Related Tutorials