java - Passing an object between the methods which has to keep adding data in all the methods -


i have requirement of passing object between methods , adding data below example. below written code programming practice?

public void parentmethod(){ propertybean propertybean = new propertybean(); propertybean.setvalue1("value1"); propertybean = childmethod(propertybean); propertybean.setvalue3("value3"); } public propertybean childmethod(propertybean propertybean){ propertybean.setvalue2("value2"); return propertybean; } 

you dont need return object

childmethod(propertybean); 

this call make sure value2 set object. objects passed reference in java (except primitive types)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

android - Go back to previous fragment -