I'm trying to make a variable out of the result of a for loop. First of all is this possible? If it is possible how do i do it? This is my code so far:
Random r = new Random();
Random n = new Random();
int p = (int)(n.nextInt(14));
for (int i = 0; i < p; i++) {
char c = (char) (r.nextInt(26) + 'a');
System.out.println(c);}
String word = ("output of forloop goes here");
I want to put all the randomly generated letters into one word using the for loop. How do I do this?