how fill a 2d array with random strings

Viewed 1340

As the title say i want to populate a 2d array with random strings, in this case "_" and "W", and i made both the 2d array and a random string generator but i can find a away to populate the array created with the string generated

import java.security.SecureRandom;

public class Array_Generator {
public static void main(String[] args) {

    int row = 5;
    int col = 5;
    int[][] grid = new int[row][col];
    String AB = "_W";
    SecureRandom rnd = new SecureRandom();
    for( int i = 0; i < grid.length; i++ ) {
        StringBuilder sb = new StringBuilder(row);
        sb.append( AB.charAt( rnd.nextInt(AB.length()) ) );
        sb.toString();


    }
System.out.println(sb);

If i do this i get the row like i want, but i cant find a away to do the next ones.

Any help would be apreciated.

3 Answers
Related