Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Random;

public class Main {
    public static String getRandomStr() {
        return getRandomStr(20);
    }

    public static String getRandomStr(int len) {
        Random rd = new Random();
        String retStr = "";
        do {
            int rdGet1 = Math.abs(rd.nextInt()) % 10;

            int rdGet2 = Math.abs(rd.nextInt()) % 26 + 65;
            retStr = retStr + rdGet1 + (char) rdGet2;
        } while (retStr.length() < len);

        return retStr;
    }
}