I am pretty new to this language. I have an object and I want to pass it by value to another method:
// Drawings
class Drawings
{
// Has some variables
Drawings()
{
}
// Hass some methods
}
class History
{
ArrayList<Drawings> prevDrawings;
History()
{
this.prevDrawings = new ArrayList<Drawings>();
}
void add(Drawings newDrawing) {}
}
Now, say I have a Drawings myDrawing
and History myHistory
, and I want to pass myDrawing
by value to myHistory
. The following way passes it by reference:
myHistory.add(myDrawing);
How can I then pass this by value?