Java Random Number getRandNum(int num)

Here you can find the source of getRandNum(int num)

Description

get Rand Num

License

Apache License

Declaration


public static String getRandNum(int num) 

Method Source Code

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

import java.util.Random;

public class Main {

    public static String getRandNum(int num) {
        String res = "";
        if (num < 1)
            return res;
        String arr[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
        for (int i = 0; i < num; i++) {
            Random ran = new Random();
            int index = ran.nextInt(10);
            res = res + arr[index];//from   ww w. ja va2  s .  c  o  m
        }
        return res;
    }
}

Related

  1. getNumbersAndAlphabet()
  2. getNumString(int length)
  3. getPhoneNumber()
  4. getPositiveNumber(int maximum)
  5. getRandNum(int charCount)
  6. getRandNum(int num)
  7. getRandNumber(int maxNumber)
  8. getRandomDouble(double max, String decimalFormat)
  9. getRandomNum()