When I say:
StringBuilder strBuilder = new StringBuilder(); for(char alph = 'a'; alph <= 'z'; alph++) { strBuilder.append(alph); System.out.println(strBuilder); }
output:
"a
ab
abc
abcd..."
What I want to do now is generate a Char[][] based on user input for the dimensions. Then I will randomly generate characters from the alphabet to fill the array. Should I use the StringBuilder class for this? Or is there a simple way to generate random letters with math.Random?
That is I know how to generate a random letter between a-z:
Random r = new Random(); char c = (char)(r.nextInt(26) + 'a');
However; i'm not sure how to store those values into a Char[][]. So I figured maybe I could do it with StringBuilder.