Forums Register Login
Drag n Drop Question
This was a question from whizlabs:
The Bold words are what i have filled in the code

This code Compiles fine and output is sorted by name and age of employees.

At the line where i have marked 1 instead of :
public int compare(T obj1, T obj2)//1
I made it
public int compare(Employee obj1, Employee obj2)//1

That means i used Employee instead of T.
The output of both the programs is same
I wanted to konw that is it wrong to do this in the exam?
This does not compile:
public int compare(Employee obj1, Employee obj2)//1

My compiler says:
The type MyComparator<T> must implement the inherited abstract method Comparator<T>.compare(T,T).

public int compare(Employee obj1, Employee obj2)//1
It compiles fine in JDK 1.5 and the output is :
Daisy of age 22
Daisy of age 40
George of age 29
Jacob of age 30
Ok strange, cause I pasted your code in Eclipse, and compiled it with version 1.5 and it does not compile:-)
Works here textpad and Java 1.5

Compiles and runs both versions
But yet nobody answered me...??
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter

This thread has been viewed 670 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 22, 2018 19:58:19.