Class Cast Exception in most of the test cases related to Linked List

In this module, we have to implement all the functionalities using LinkedList as opposed to ArrayList used previously.
So, I copied the code of “ArrayList files” to “LinkedList files” and just changed the data type of list to LinkedList. But it is showing me “class cast exception”. I did all the type-casting that was required in the code. I know what the exception means and tried some things too. But still the same error. So, what am I doing wrong?

You are probably getting class cast exception, because you would have copied all the contents of the test file, now the Class name of the both the files would say ArrayListImpl.
Check this

No sir. I have checked it. N that is not the case.


Please look at this website. It may give you some insight.

I have read this article and some other articles previously. But still not able to find my mistake. I would like to complete maximum number of modules today. So, kindly help me.

Hey,

It’s looks like you copied everything in the linkedlist file. Don’t copy whole thing because its difficult for you to find you the mistake :slight_smile:
Implement function by function using linkedlist.
As per your error it’s due to type cast or you mixed up with same name of both the class
Refer to this -

Closing this topic as there is no response since last 12 hours. Please feel free to create a new topic and post this question as a reference link in the description of the new topic.