Java ThreadLocalRandom getElement(boolean[] array)

Here you can find the source of getElement(boolean[] array)

Description

get Element

License

Apache License

Declaration

public static boolean getElement(boolean[] array) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class Main {
    public static boolean getElement(boolean[] array) {
        return array[getInt(array.length)];
    }/* ww  w  .j a v a  2  s.co  m*/

    public static byte getElement(byte[] array) {
        return array[getInt(array.length)];
    }

    public static char getElement(char[] array) {
        return array[getInt(array.length)];
    }

    public static short getElement(short[] array) {
        return array[getInt(array.length)];
    }

    public static int getElement(int[] array) {
        return array[getInt(array.length)];
    }

    public static long getElement(long[] array) {
        return array[getInt(array.length)];
    }

    public static float getElement(float[] array) {
        return array[getInt(array.length)];
    }

    public static double getElement(double[] array) {
        return array[getInt(array.length)];
    }

    public static <E> E getElement(E[] array) {
        return array[getInt(array.length)];
    }

    public static <E> E getElement(List<E> list) {
        return list.get(getInt(list.size()));
    }

    public static int getInt() {
        return ThreadLocalRandom.current().nextInt();
    }

    public static int getInt(int bound) {
        return ThreadLocalRandom.current().nextInt(bound);
    }

    public static int getInt(int min, int max) {
        return getInt(max + 1 - min) + min;
    }
}

Related

  1. generateString(Random rng, String characters, int length)
  2. generateStringFromCharacters(final Random random, final char[] validChars, final int min, final int max)
  3. genRandomString()
  4. get_a_number_between_min_and_max(int min, int max)
  5. getBoolean()
  6. getInt(int bound)
  7. getLetter()
  8. getRandom()
  9. getRandom(int p)