This question is in continuation with my previous question
So, I want create a list with suppose 5 a
characters, 10 b
, 20 c
and 10 d
.
for(char chr = 'a'; chr <= 'c'; chr++){
alphabetList.addAll(Collections.nCopies(5, chr));
}
With above code I can add 5 copies of each char. My question is how can we add 5 a
characters, 10 b
, 20 c
and 10 d
.
How can we do this. Any functional way?