Java Random Number getNumbersAndAlphabet()

Here you can find the source of getNumbersAndAlphabet()

Description

get Numbers And Alphabet

License

Open Source License

Declaration

public static String getNumbersAndAlphabet() 

Method Source Code


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

import java.util.Random;

public class Main {
    private final static String randString = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private final static int length = 6;

    public static String getNumbersAndAlphabet() {

        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            sb.append(getRandomString(random.nextInt(randString.length())));
        }/*from w  w w. ja  va 2s.  c om*/

        return sb.toString();
    }

    private static String getRandomString(int num) {
        return String.valueOf(randString.charAt(num));
    }
}

Related

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