function - Java Array List and object passing -


i have list of string in code. passing list of string function , modifying it.( adding/deleting few elements list).but dont want these changes reflected in caller function. changes should reflected in callee function. because objects passed reference, think changes getting reflected in both functions. how can avoid this. please help

you can use clone method.

caller(arraylist<string> a) {     callee((list<string>)a.clone()); }  callee(list<string> acloned) {  } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -