This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ClassCastException" Watch "ClassCastException" New topic
Author

ClassCastException

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
Sheriff

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
sscce.org
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
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.
 
jQuery in Action, 2nd edition
 
subject: ClassCastException
 
Similar Threads
Loose Coupling
Aggregation and Composition
Sorting
Static methods in Java Interfaces?
Local inner classes