You can do
if (a instanceof B) {
b = (B)a;
}
which will guarantee you won't get a class cast exception. However, you
need to do something if a is not an instance of B.
Gunter D'Hondt wrote:
I'm currently trying to use polymorphism but I'm always getting a
ClassCastException:
--------------------------
public class A {}
public class B extends A {}
public class C {
public void foo(A a) {
B b = new B();
b = (B) a;
}
}
--------------------------
How am I doing wrong here?
Regards,
Gunter
Ralph Goers <[EMAIL PROTECTED]>
12/08/2005 08:31
Please respond to
[email protected]
To
[email protected]
cc
Subject
Re: interface implementation
It sounds like maybe you want the Factory in cocoon.xconf. Get your
objects from it and then store them in the session.
Gunter D'Hondt wrote:
How can I define an implementation of an interface inside the
cocoon.xconf
without using the Avalon component-tag coz the class should not be shared
over all users since it should be possible to place it inside the session
object?
Regards,
Gunter D'Hondt
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]