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

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

/****** * 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

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!