Java examples for Collection Framework:Array Random Value
populate String Array with random number
//package com.java2s; public class Main { public static void main(String[] argv) { int numberOfItems = 42; System.out.println(java.util.Arrays .toString(populateStringArray(numberOfItems))); }/* w ww. ja va 2 s . c o m*/ public static String[] populateStringArray(int numberOfItems) { final String partialWord = "partialArrayParallel"; String[] dummyStringArray = null; if (numberOfItems > 0) { dummyStringArray = new String[numberOfItems]; for (int i = 0; i < numberOfItems; i++) { final double randomNumber = (Math.random() * numberOfItems); final StringBuilder sb = new StringBuilder(partialWord) .append(randomNumber); dummyStringArray[i] = sb.toString(); } } return dummyStringArray; } }