Quantcast
Channel: What else can throw a ClassCastException in java? - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by OldCurmudgeon for What else can throw a ClassCastException in java?

And finally, someone hacked the String intern table for the string "a". See an example of how it can be done here.

View Article



Answer by shiladitya for What else can throw a ClassCastException in java?

Well maybe because C1 is an abstract class, and the get function also returns on object(of a subclass of C1 of course) which was casted to C1 before returning?

View Article

Answer by Ed Plese for What else can throw a ClassCastException in java?

The ClassCastException can occur if the same class was loaded by multiple different classloaders and instances of the classes are being shared between them. Consider the following example hierarchy....

View Article

Answer by Keppil for What else can throw a ClassCastException in java?

One reason could be that the part of the code inserting the object uses a different classloader than the code retrieving it. An instance of a class can not be cast to the same class loaded by a...

View Article

What else can throw a ClassCastException in java?

This is an interview question. The interview is over, but this question is still on my mind. I can't ask the interviewer, as I did not get the job. Scenario: put object of class C1 in to a cache with...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images