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 getRandom(int len, String[] arr) {
        String s = "";
        if (0 < len && null != arr && arr.length >= 0) {
            Random ra = new Random();
            int arrLen = arr.length;
            for (int i = 0; i < len; i++) {
                s += arr[ra.nextInt(arrLen)];
            }
            return s;
        } else {
            return s;
        }
    }
}