public List<String> createList(int listSize) { Random rand = new Random(); List<String> wordList = sourceWords. stream(). limit(listSize). collect(Collectors.toList()); return wordList; }
那么如何和在哪里可以使用我的随机?
public List<String> createList(int listSize) { Random rand = new Random(); List<String> wordList = rand. ints(listSize,sourceWords.size()). mapToObj(i -> sourceWords.get(i)). collect(Collectors.toList()); return wordList; }