possible lossy conversion from int to short
问题 I have defined array gx, array arr to be short type. but why the operation at left may end up with int type and I must cast it into short? the compiler error is possible lossy conversion from int to short. this is my code. public PixImage sobelEdges() { short gy=0; for(int x=1;x<width-1;x++){ for(int y=1;y<height-1;y++){ // if(x=){ for(int z=0;z<3;z++){ gx[x][y][z]=arr[x-1][y-1][z]-arr[x+1][y-1][z]+2*arr[x-1][y][z]-2*arr[x+1][y][z]+arr[x-1][y+1][z]-arr[x+1][y+1][z]; } // } } } return this; //