Java - Write code to get Random Password in digits

Requirements

Write code to get Random Password in digits

Demo

//package com.book2s;

import java.util.Random;

public class Main {
    public static String getRandomPass(Integer length) {
        Random randGen = new Random();
        char[] numbersAndLetters = ("0123456789").toCharArray();
        char[] randBuffer = new char[length];
        for (Integer i = 0; i < randBuffer.length; i++) {
            randBuffer[i] = numbersAndLetters[randGen.nextInt(10)];
        }/*  w w  w  .  ja v  a 2s.  co  m*/
        return new String(randBuffer);
    }
}