I wanted to have a function that returns a copy of the object it receives, to use it somewhere else. This is what I wrote:
public static PObject Instantiate(PObject obj) { PObject other = obj; objects.add(other); return other; } But when I print obj + " " + other, it outputs:
PObjects.Wall@5315b42e PObjects.Wall@5315b42e How can I return the same object stored in a different variable?
PObject other = new PObject(obj);.equals(andhash) exist to allow code to determine if object instances areequalbased on whatever criteria you choose.