public static String createRandomNum(int length) {
        if (length < 0) {
            throw new IllegalArgumentException("长度不能小于0");
        }
        char[] chars = new char[length];
        for (int i = 0; i < length; i++) {
            chars[i] = (char) ((Math.random() * 10) + 48);
        }
        return new String(chars);
    }
public static String createRandomNum ( int length ) { if ( length < 0 ) { throw new IllegalArgumentException ( "长度不能小于0" ) ; } char [ ] chars = new char [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { chars [ i ] = ( char ) ( ( Math . random ( ) * 10 ) + 48 ) ; } return new String ( chars ) ; }
生成随机字符串（只包含数字）

@param length 长度
@return 随机字符串