ClassCastException in Qmoney Module 8

In QMoney Module8
At line 115 I am getting ClassCastException. However the return type (i.e. List) of the method calculateAnnualizedReturnParallel() matches to that required in the output.

Hi @Aditya2811
Looks like you are facing challenges in the current module.

Below is a link to all the FAQ’s for the current module

Below are a few similar topics raised by other users which you might find usefull

Note - This is a BETA Feature,if you find this helpful, kindly let us know.
Feedback link -

Kindly mark this as a solution if this has helped you solve your query

Hi @Aditya2811,

So, the complete error is like this

java.lang.ClassCastException: com.crio.warmup.stock.dto.AnnualizedReturn cannot be cast to java.lang.Comparable

Any thoughts?
How does Collections.sort work? Do we need to extend the objects (AnnualizedReturn) with any classes?

Do we need to implement a compareTo() function…If so then where?

Which type of object do you want to sort? We’ll have to implement sorting logic in that class?

I simply added compareTo() function in…but now i get AssertionFailedError at line 121…the list I am getting is {“AAPL”, “GOOGL”, "MSFT


Did you try debugging the issue by setting breakpoints? What is your hypothesis on the discrepancy?

Yeah the list output is wrong…can you just help me with the sorting logic

PLEASE help…I don’t understand what to do…and I am afraid that I will have to change codes written in past modules.

Hey, hope this was sorted out. Closing the ticket for now. Kindly reopen if required.

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.