I am working on a java program. where I have taken an input string and I am putting each char from a string in a 4*4 matrix. If the input string length is small than 16 i.e 4*4 matrix, then I am adding padding '#' char.
But Now, suppose the input string length is more than 16 then I want to create a new array and put remaining chars into it. I can't use a vector, set, map. So How can I code now?
here is some code. key=4.
 char[][] giveMeNewArray() {
    char[][] matrix = new char[key][key];
    return matrix;
 }
 void putCharIntoMatrix() {
    int counter = 0;
    char[][] myArray = giveMeNewArray();
    System.out.println("myArray: " + myArray);
    for (int i = 0; i < key; i++) {
        for (int j = 0; j < key; j++) {
            if (counter >= inputString.length()) {
                myArray[i][j] = '#';
            } else {
                myArray[i][j] = inputString.charAt(key * i + j);
            }
            counter++;
        }
    }
    for (int i = 0; i < key; i++) {
        for (int j = 0; j < key; j++) {
            System.out.print(myArray[i][j] + "  ");
        }
        System.out.println();
    }
}
 
    