class Parent {
}
class Child extends parent {
String something;
//get and set
}
Parent parent = getChildObject();
//without casing getChildObject() to Child object. i cannot do child.getSomething(); Can i do something like parent.getProperty("something"); to get the value?
The correct way to do this is:
if (parent instanceof Child) {
String something = ((Child) parent).getSomething();
}
You can also do this by using reflection, but that is a lot more complicated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With