Java examples for java.util:List Element
populate String List with random value
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] argv) { int numberOfItems = 42; System.out.println(populateStringList(numberOfItems)); }/*from w ww . ja v a 2 s . c om*/ public static List<String> populateStringList(int numberOfItems) { final String partialWord = "partialListParallel"; List<String> dummyStringList = null; if (numberOfItems > 0) { dummyStringList = new ArrayList<String>(); for (int i = 0; i < numberOfItems; i++) { final double randomNumber = (Math.random() * numberOfItems); final StringBuilder sb = new StringBuilder(partialWord) .append(randomNumber); dummyStringList.add(sb.toString()); } } return dummyStringList; } }