Java Programming Please Help Create Method Method Gethighestincolumnindex Pass Two Dimensi Q37124514

Java Programming: Please help me create this method

Method getHighestInColumnIndex – pass in a two-dimensionalragged array of doubles and a column index and returns the index ofthe largest element in that column. Column index 0 is the firstcolumn in the array. If a row doesn’t contain that column, it isnot an error, that row will not participate in this method.


Solution


If you have any doubts, please give mecomment…

public static int getHighestInColumnIndex(doublearr[][], int col_index){

int highest_ind = 0;

for(int i=0; i<arr.length;i++){

if(arr[i].length>col_index){

if(arr[i][col_index]>arr[highest_ind][col_index])

highest_ind = i;

}

}

return highest_ind;

}

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.