java - Is there any way to access child object's variable when the object is referred by its super class? -


There is another way to access the object object's variable when the object is the object to the child casting the caste class?

  class parent {int parentData; } Children of the class parents {int childData; } Original obj = new child (); Obj.childData = 10; // Error getting (obj) (child) .childData = 10;              Varies with the class and I tried to refer to all class squared objects with parent class. At some point, what should I do with hair variables? Do I need to redesign?  

Only the behaviors that parents should have in the parent class are normal for all children.

If you are trying to implement in the original class, then in reality it is normal behavior that you may want to look at.

If you are applying, there are different behaviors on child organs, Shweta is in this original class, but apply it in child classes. If this implementation shares shared parts, then you mother it Can be removed from a normal method in a parent or auxiliary class.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -