Check if char exists in java
If I have a string that contains "Cat"
how could I check before hand if anything exists in each individual charAt case.
Here is the sample code


        for (int i = 0; i < array.length; i++)
        {
            System.out.println();
            for (int j = 0; j < size; j++)
            {
                System.out.print(array[j].charAt(i) + " ");
            }
        }

Once i reaches 3 you would get an out of bounds exception. Is there a way that it could print an empty space? 
Check if char exists in java
===

If I have a string that contains "Cat"
how could I check before hand if anything exists in each individual charAt case.
Here is the sample code


        for (int i = 0; i < array.length; i++)
        {
            System.out.println();
            for (int j = 0; j < size; j++)
            {
                System.out.print(array[j].charAt(i) + " ");
            }
        }

Once i reaches 3 you would get an out of bounds exception. Is there a way that it could print an empty space? 