Comparing values inside a 2D Array in java -


i'm working on question need compare values inside 2d array in java. example:

int n = 2, c = 2; int [][] arr = new int[n][c];  system.out.println("enter values 2d array: ");  for(int i=0; i<n;i++) {     (int j=0;j<c;j++) {         arr[i][j]=in.nextint();     }      } 

so in above code, user enters values inside 2d array. want compare if arr[i]>=0 , arr[j]>=0 separately , if yes, need perform other operation on this.

but i'm not able way. example:

for(int i=0; i<n;i++) {     (int j=0;j<c;j++) {         if (arr[i]>=0 && arr[j]>=0) {             //some operation//         }     } } 

kindly suggest me way operation - comparing values individually. thank you.

arr1[i] array of integers, not integer, can't compare integer. arr1[i][j] int, , can compared integers.

if (arr[i][j]>=0) valid syntax, it's not clear if that's want.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -