void (String[] words) { if (words.length <= 1) { return; } int len = words.length; int totalCommas; if (len > 3 && len <= 6) { totalCommas = rand(0, 1); } else if (len > 6 && len <= 12) { totalCommas = rand(0, 2); } else { totalCommas = rand(1, 4); } while (totalCommas > 0) { int i = rand(0, words.length - 1); String word = words[i]; if (!StringUtil.endsWithChar(word, ',')) { words[i] = word + ","; } totalCommas--; } }