Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago

Question

=+ Are you interested in creating or

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago