Question: JAVA Need code for compare method for override import java.util.*; @SuppressWarnings(rawtypes) public class Table implements Iterable { private Comparable data[][]; // Creates a table that

JAVA

Need code for compare method for override

import java.util.*;

@SuppressWarnings("rawtypes") public class Table implements Iterable { private Comparable data[][]; // Creates a table that is a copy of the given input array public Table(Comparable data[][]) { int rows = data.length; int cols = 0; if (rows > 0) cols = data[0].length; this.data = new Comparable[rows][cols]; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { this.data[i][j] = data[i][j]; } } }

// Comparator class for comparing with respect to a single column public static class ByColumn implements Comparator { public ByColumn(int col, boolean ascending) { ascending = true; for(int i = 0; i < data.length-1; i++) { if(data[i] >= data[i+1]); ascending = false; }

@Override public int compare(Comparable[] o1, Comparable[] o2) { // TODO return 0; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!