Saturday, 15 February 2014

java - Parent notification within array of objects -


So, I'm working on a Java program that uses a built-in class (we call it "hair" Are). However, within this class, you can also create an array of objects that are the objects of class "hair" Bal (level 1)

  • Child (level 2)
  • < / Li>
  • Child (Level 1)

Now, the issue I am coming to is: Let's say, for example , I change a field in level 2. I want to notify Level 1, but I do not know how to inform level 1. Is there any way in which object can be talked with that object which is it? Now, if I was using Android, then maybe I could use a broadcast receiver, but I do not know anything in this way in Java or in a way I'm talking directly to the "parent" hair level . any suggestion?

An object must be aware of its parents to talk to their parents. For example:

  class child {child parent; Public hair (hair_paint) {parent = _parent; } Public Zero Informed (String Data) {... what you need to do} Public Zero Transformation Here (...) {... if (parent! = Null) {parent.notify (...); }}  

Tell me if you need more

Edit: Notify the object stack up or down, but not in both directions, because it can cause problems and not to notify the notification code without the code


No comments:

Post a Comment