# Thread: Minimum of 2d Array

1. Member
Join Date
Feb 2011
Posts
24
Rep Power
0

## Minimum of 2d Array

trying to get the minmum of a 2d array... not sure what im doing wrong.

Java Code:
```	int[][] toReverse = {
{11,5,5,5,5},
{3,7,8,9,10},
{1,2,3,4,5},
{1,2,3,4,5},
{1,2,3,4,5}
};

int min = toReverse[0][0];
for (int i=0; i<toReverse.length;i++){
for(int k=1;k<toReverse.length;k++){
if(toReverse[i][k]<min)
min=toReverse[i][k];
}
}
System.out.print(min);```

2. Moderator
Join Date
Jul 2010
Location
California
Posts
1,641
Rep Power
9
not sure what im doing wrong
And neither are we, unless you provide a more detailed description of the problem. Does it compile? Are there exceptions? Does it behave properly?

3. Why are you starting k at 1?

4. Member
Join Date
Feb 2011
Posts
24
Rep Power
0
starting at k=1 because i set the min to [0][0] already, which im not sure is right. anyways im trying to get the minimum value of the array which should be 1 but the output is 2.

5. Hint- Draw a 2D array, and label the "coordinates" of each index. For example, the coordinates of the index holding the number 10 is [1][4].

6. Member
Join Date
Feb 2011
Posts
24
Rep Power
0
yea i know how coordinates of arrays work. that doesnt help at all...

7. Originally Posted by Spyderpig
yea i know how coordinates of arrays work. that doesnt help at all...
Sorry, but if you knew how arrays worked, you wouldn't be having this issue. But if you're unwilling to try some simple advice, I'm not going to waste my time.

Much luck.

8. Member
Join Date
Feb 2011
Posts
24
Rep Power
0
advice helps people. what you said is the equivalent of saying the world is round. we all know this. thanks for failing.

9. Originally Posted by Spyderpig
advice helps people. what you said is the equivalent of saying the world is round. we all know this. thanks for failing.
Failing? I'm not the one who can't figure out basic arrays. /immature

I was perfectly willing to offer you some more hints, had you tried my first one and still not understood what I was getting at. I still think you'd figure it out if you followed my advice.

Don't worry, I'm sure somebody will eventually come around and spoonfeed you your blatant error. But your terrible attitude and apparent laziness pretty much guarantee a short career in programming.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•