Java Random Int randomStringNumbers(int len)

Here you can find the source of randomStringNumbers(int len)

Description

Generate a string only with digits from 0 to 9, randomically, with the length of len parameter.

License

Open Source License

Parameter

Parameter Description
len The length of the random string to be generated

Return

A string with length len, with digits randomically generated.

Declaration

public static String randomStringNumbers(int len) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**Generate a string only with digits from 0 to 9,
     * randomically, with the length of len parameter.
     * @param len The length of the random string to be generated
     * @return A string with length len, with digits randomically
     * generated.*//*  w ww.  java  2 s. c  o  m*/
    public static String randomStringNumbers(int len) {
        String s = "";
        for (int i = 0; i < len; i++)
            s = s + (int) (Math.random() * 10);
        return s;
    }
}

Related

  1. randomString(int length)
  2. randomString(int min, int max)
  3. randomString(int numChar)
  4. randomString(int size)
  5. randomString(int size, String... keys)
  6. randomtest(int max)
  7. randomText(int length)
  8. randomWithinRange(int min, int max)
  9. randomWithRange(int min, int max)