-, , ,
int[][] array = {{1, 20},
{1, 14},
{2, 15},
{2, 67},
{3, 55},
{3, 24},
{4, 95},
{4, 23}};
, , , java. , . , - , .
while (array[0][count] < array[count].length)
, , . , , - , (2- ) (1- ). .
int count = 0;
while(count < array.length){
count++;
}
, 0 1,
int count = 0;
while(count < array.length){
int keyVal = array[count][0];
int numVal = array[count][1];
count++;
}
Finally, your sample data has only possible values for keys 1-4. If all of this ever happens, it's 1-4, then your storeMax variable will work to store the results. Otherwise, you will want to use the map, as Prashant says in the comments above.
So, if the keys will always be between 1-4, you can perform a check in a loop and save them.
while(count < array.length){
int keyVal = array[count][0];
int numVal = array[count][1];
if(storeMax[keyVal-1] < numVal){
storeMax[keyVal-1] = numVal;
}
count++;
}
Remember that arrays are based on 0. That's why you should use keyVal-1.