I have a method called xyz which returns an object.
private XYZ xyz() {
return abc;
}
I want to use this method in 2 different places but I want to call the method only once.
I mean for the first time I am calling the method to get the object.
XYZ aaa = xyz();
Here I have an object 'aaa'. And I want to use the same object in different place, but I can't use this object as this is private. So what I want to do is to create a new object called 'bbb' from 'aaa' without calling the method. Just like bbb = aaa; Please help me how to create a new object from existing object or create a duplicate object with different name.
Thanks in advance