I have 4x4 character array here and I need to get the common value of the character that is on the edge of the array...I tried the solutions from other questions similar to my problem, but I am still getting the same error.,
here's my code..
//arr2[][]
// arr2[3][0] = 'H';
// arr2[3][1] = 'E';
// arr2[3][2] = 'L';
// arr2[3][3] = 'P';
//arr3[][]
// arr3[1][3] = 'T';
// arr3[2][3] = 'O';
// arr3[3][3] = 'P';
//I specifically need the get the 'P' at [3][3]..
for(o = 0;o<count;o++){
char letter = out.charAt(o);
for(int m = 0; m < 4; m ++){
for(int n = 0; n < 4; n ++){
if(Arrays.asList(arr3[m][n]).contains(letter)){
r = m;
c = n;
}
}
}
right = arr2[r][c+1];
left = arr2[r][c-1];
up = arr2[r-1][c];
down = arr2[r+1][c];
if(o==0){
if(c==0){
if(r==0||r==3){
if(right!=null){
l = right;
}
}else{
if(right!=null){
l = right;
}else if(up!=null){
l = up;
}
}
}else if(c==3){
if(r==0||r==3){
if(left!=null){
l = left;
}
}else{
if(left!=null){
l = left;
}else if(up!=null){
l = up;
}
}
}else{
if(r==0||r==3){
if(left!=null){
l = left;
}else if(right!=null){
l = right;
}
}else{
if(left!=null){
l = left;
}else if(right!=null){
l = right;
}else if(up!=null){
l = up;
}
}
}
}
}else if(o==(count-1)){
if(vertical == 1){
if(c==0){
if(r==0||r==3){
if(right!=null){
l = right;
}
}else{
if(right!=null){
l = right;
}else if(down!=null){
l = down;
}
}
}else if(c==3){
if(r==0||r==3){
if(left!=null){
l = left;
}
}else{
if(left!=null){
l = left;
}else if(down!=null){
l = down;
}
}
}else{
if(r==0||r==3){
if(left!=null){
l = left;
}else if(right!=null){
l = right;
}
}else{
if(left!=null){
l = left;
}else if(right!=null){
l = right;
}else if(down!=null){
l = down;
}
}
}
}
}else{
if(vertical == 1){
if(c==0){
if(right!=null){
l = right;
}
}else if(c==3){
if(left!=null){
l = left;
}
}else{
if(right!=null){
l = right;
}else if(left!=null){
l = left;
}
}
}
}
k = Character.toString(letter);
letr = Character.toString(l);