Java Random Number getNumString(int length)

Here you can find the source of getNumString(int length)

Description

get Num String

License

Apache License

Declaration

public static String getNumString(int length) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    public static final String NUMBERCHAR = "0123456789";
    private static Random random;

    public static String getNumString(int length) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            sb.append(NUMBERCHAR.charAt(random.nextInt(NUMBERCHAR.length())));
        }/*from   w  w  w  .j  a  v a2 s .  c  o  m*/
        return sb.toString();
    }
}

Related

  1. getNumberedUsername(String fn, String ln)
  2. getNumberInRange(int minimum, int maximum)
  3. getNumberLong()
  4. getNumbers()
  5. getNumbersAndAlphabet()
  6. getPhoneNumber()
  7. getPositiveNumber(int maximum)
  8. getRandNum(int charCount)
  9. getRandNum(int num)