0
Netbeans extent Convert help
*(the classes Doctor and Teacher extends Person) Person p1=new Doctor(); How can I Convert p1 to a Teacher or only a person?
1 ответ
+ 5
You can not convert p1 to Teacher as they are sibling classes, but you can cast p1 to person like this:
Person p2 = (Person) p1;