File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ClassCastException" Watch "ClassCastException" New topic


Rahul Saple
Ranch Hand

Joined: Aug 02, 2006
Posts: 46
Ok here's the scene ........ i've gotta function which i need to call whose signature goes like this

and is inside a class named AdvertisementFactory.

now ive got a class called CodatAdv which has got a public static Inner class named Instantiator which implements the original AdvertisementFactory.Instantiator and has all the methods of that particular interface(AdvertisementFactory.Instantiator)

But when i call the above static method with the following parameters

i get a classcastexception at runtime....... can someone out here tell me where i'm going wrong coz as far as i know a super-interface can always point to a sub-interface of the same class.
marc weber

Joined: Aug 31, 2004
Posts: 11343

I had some trouble following you, but as far as I can tell, you're describing something like this (with a few names shortened)...

This compiles and runs fine for me.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46373
Is that really a beginner's question?

Whenever you get an Exception you need to look at its stack trace, and find out where it occurred. That should give you a hint what to do to sort it out.
I agree. Here's the link:
subject: ClassCastException
It's not a secret anymore!