# Basic Array Functions

Hi,

I would like to know how to get the value of the position of the array..

E.g.
arr[i][j]

How would I get the value of the "i" and the "j" into a variable (two seperate ones)?

Note I don't want to know what the [i][j] have been assigned, but rather than the actual numerical value of "i" and "j"...

Thanks
###### Who is Participating?

Commented:
>>How would I get the value of the "i" and the "j" into a variable (two seperate ones)?

i is an array
j is a variable

int[] row = arr[i];
int n = arr[i][j];
0

Author Commented:
I don't really understand..

To clarify my question...

arr[i][j] is a 2d array...

Say the array is now at arr[3][12] and arr[3][12] = "hello";
I want to get the number "3" and the number "12" into two separate variables..
I'm not interested in getting the string "hello", but rather the array numbers into the variable.

0

Analyst ProgrammerCommented:
vrameen,

Are you wanting the upperbound that the 2d array is filled in?
0

Commented:
>>but rather the array numbers into the variable.

But they're already in variables i and j ..?

You can of course copy them

int x = i;
int y = j;
0

Commented:
If you are looking for the position where the array value is "hello", you can search for it

int x = -1;
int y = -1;

for(int i=0; i<arr.length; i++) {
for(int j=0; i<arr[i].length; j++) {
if("hello".equals(arr[i][j])) {
x = i;
y = j;
break;
}
}
}

0

Commented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.