java - type expression must be an array type but it resolved to string -


import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*;  public class solution { static void displaypathtoprincess(int n, string [] grid){     char p;     if(grid[0][0]=='p')     {             for(int i=0;i<(n-1)/2;i++)             {                 system.out.println("up\nleft\n");             }     }     else if(grid[0][n-1]=='p')     {         for(int i=0;i<(n-1)/2;i++)         {                 system.out.println("up\nright\n");         }     }     else if(grid[n-1][0]=='p')     {         for(int i=0;i<(n-1)/2;i++)         {             system.out.println("down\nleft\n");         }     }     else if(grid[n-1][n-1]=='p')     {         for(int i=0;i<(n-1)/2;i++)         {             system.out.println("down\nright");         }     }   } public static void main(string [] args) {         scanner in = new scanner(system.in);         int m;         m = in.nextint();         int grid[] = new int[m];         for(int = 0; < m; i++) {             grid[i] = in.nextint();         }      displaypathtoprincess(m,grid);     } } 

hey, passed several conditions "grid[0][0]=='p'" in if statement can see in code, grid 2d array , p character, getting error "the type of expression must array type resolved string". have been trying figure out while haven't found solution. note: new java , trying improve myself. in advance.

the type of parameter grid 1 dimensional string array. accessing if 2 dimensional char array. should change implementation comparing string.charat(position).


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -