Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 3
    You could create a copy constructor and then do PObject other = new PObject(obj);. Commented Jun 22, 2022 at 19:18
  • 1
    That'd be explicitly not the same object; searching for "copy Java object" will get you most of the way there. equals (and hash) exist to allow code to determine if object instances are equal based on whatever criteria you choose. Commented Jun 22, 2022 at 19:18
  • 3
    Does this answer your question? How do you make a deep copy of an object? Commented Jun 22, 2022 at 19:23