Java Random createRandomStr(int digit)

Here you can find the source of createRandomStr(int digit)

Description

create Random Str

License

Open Source License

Declaration

public static String createRandomStr(int digit) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {

    public static String createRandomStr(int digit) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        int baseLength = base.length();
        Random random = new Random();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < digit; i++) {
            int number = random.nextInt(baseLength);
            stringBuilder.append(base.charAt(number));
        }/*from  w w w .java2  s  .  co  m*/
        return stringBuilder.toString();
    }
}

Related

  1. decimal_random()
  2. equalsRandomIterable(List a, List bl)
  3. extractRandomObject(Collection c)
  4. extractRandomVector(Collection c, int newSize)