random - How to randomly select 7 letters(a to z ) in java -
i want select 7 random letters z
so far have found ways select single letter https://stackoverflow.com/a/5202888/3209901
random r = new random(); char c = (char) (r.nextint(26) + 'a');
why 7 letters because , need apply conditions 7 letters - check words formed 7 letters , word length should minimum of 4 letters ......
here's java-8 solution:
new random().ints('a', 'z'+1).distinct() .limit(7).foreach(ch -> system.out.println((char)ch));
Comments
Post a Comment