Java Random Number getNumbers()

Here you can find the source of getNumbers()

Description

get Numbers

License

Open Source License

Declaration

public static String getNumbers() 

Method Source Code


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

import java.util.Random;

public class Main {
    private final static int length = 6;

    public static String getNumbers() {
        Random random = new Random();
        String result = random.nextInt(1000000) + "";

        if (result.length() != length) {
            return getNumbers();
        }//from  w  ww  .  ja v  a2s . c o  m
        return result;
    }
}

Related

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