How do I send a stream of data back to the “parent” or calling instance / object?
“parent” is not the right word here, as ccc doesn’t extend bbb.
Suppose your class bbb has a field data which you want to update:-
class bbb{
private String data;
public String getData(){
return data;
}
public void setData(String data){
this.data=data;
}
}
In your your class bbb, there is a call to a method by ccc instance, which need to update data field of bbb :-
ccc doStuff = new ccc(this);
doStuff.goAndConquer()
Your class ccc will look like below:-
class ccc{
private bbb b;
public ccc(bbb b){
this.b=b;
}
//Now while processing your file just do below
// b.setData(dataToBeSet);
}
Just pass the instance of bbb to ccc and update it.
1
solved java need a child object to change data in the parent [closed]