Char array input error

I’m not able to give 2D char array input.
Help me, its showing errors in the Rat in a maze problem.

Hi Pranjal
Make sure that you are defining array in string data type and taking M inputs in char and then using an another put one by one values from that string using charAt().
try to implement this logic and let me know if you still face any issue.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Not getting the way how to insert the characters to array.

Hi Pranjal
Hope this will help you:-

 Scanner s=new Scanner(System.in);
    
        int m=s.nextInt();
        int n=s.nextInt();

        String[][] maze=new String[m][n];
        int[][] v=new int[m][n];
        int[][] sol=new int[m][n];
        for(int i=0;i<m;i++)
        {

            String str=s.next();
            for(int k=0;k<str.length();k++) {
                char cc=str.charAt(k);
                if(cc=='X') {
                    v[i][k]=1;
                }
            }          

       }
    m--;
    n--;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Ok Sir, I’ll try n get back to u. Thank you!