Java - Write code to get Random Number by length

Requirements

Write code to get Random Number by length

Demo

//package com.book2s;

import java.util.Random;

public class Main {
    public static void main(String[] argv) {
        int length = 42;
        System.out.println(getRandomNumber(length));
    }/*from   w  w  w  . ja v a  2  s  . co  m*/

    private static final String RANDOM_NUMBERS = "1234567890";

    public static String getRandomNumber(int length) {
        if (length <= 0)
            return null;

        StringBuffer sb = new StringBuffer();
        Random r = new Random();
        int range = RANDOM_NUMBERS.length();
        sb.append(RANDOM_NUMBERS.charAt(r.nextInt(range - 1)));// ???????0
        for (int i = 0; i < length; i++) {
            sb.append(RANDOM_NUMBERS.charAt(r.nextInt(range)));
        }
        return sb.toString();
    }
}