Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/****** * Q3: [15 marks] * create Q3 class to implement comparator for a TreeSet. The purpose of * the comparator is to compare the

image text in transcribed
image text in transcribed
/****** * Q3: [15 marks] * create Q3 class to implement comparator for a TreeSet. The purpose of * the comparator is to compare the alphabetic order of integers. With 13, * the order of Integer elements will be sort according to the order of * digit Unicode. * For example, the value of {11,3,31,2} will return {11,2,3,31} * NOTE: You don't need to compare each digit one by one. Just compare them as strings. **** *****/ System.out.println("Q3 - [15 marks] Set Integer set = new TreeSet(new Q3(); Integer[] arr3 = {11,3,31,2}; set.addAll(Arrays.asList(arr3)); for (Integer element: set) System.out.print(element+"\t"); System.out.println(); class Q3 implements Comparator{ @Override public int compare(Integer x, Integer y) { //TODO return; }

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

Step: 3

blur-text-image

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago