"Luck is when opportunity meets preparation"
ok try this. make your parent class public as well. then get back to us
Originally posted by adeel ansari:
the problem is not that.
as we can pass java.sql.Date to java.util.Date, without any casting.
java.util.Date d = new java.sql.Date();
and we can do vice versa by add casting like,
java.sql.Date d = (java.sql.Date)new java.util.Date();
because sql.Date is a sub-class of util.Date. then why not this,
Child c = (Child)new Parent(); // Child is a sub-class of Parent
"Luck is when opportunity meets preparation"
Originally posted by Joyce Lee:
The p1, referencing to a Parent Object, cannot be cast to Child because a Parent is not a Child.
would it work?
Vector vtr = new Object();
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand