Java Random randomCharacterVector(int size)

Here you can find the source of randomCharacterVector(int size)

Description

Creates a random vector of chars of length size.

License

Open Source License

Parameter

Parameter Description
size the length of the random vector
random the random number generator used to generate the random vactor

Return

a random vector of char elements

Declaration

public static char[] randomCharacterVector(int size) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.*;

public class Main {
    private static Random random = new Random();

    /**//from   www .  jav a2 s  .  co m
     * Creates a random vector of chars of length <em>size</em>.
     * @param size the length of the random vector
     * @param random the random number generator used to generate the random vactor
     * @return a random vector of char elements
     */
    public static char[] randomCharacterVector(int size) {
        char[] retVal = new char[size];
        for (int i = 0; i < size; i++) {
            retVal[i] = (char) ('A' + random.nextInt((int) ('Z' - 'A')));
        }
        return retVal;
    }
}

Related

  1. random_g729()
  2. random_g729()
  3. randomAgain()
  4. randomAlpha()
  5. randomAlternate(char c)
  6. RandomCode()
  7. randomCode()
  8. randomCSeq()
  9. randomData(Random random, int length)