Skip to content

Instantly share code, notes, and snippets.

@LenarBad
Created November 20, 2017 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LenarBad/268a71c7104ed29e0c0343bf7867e9ba to your computer and use it in GitHub Desktop.
Save LenarBad/268a71c7104ed29e0c0343bf7867e9ba to your computer and use it in GitHub Desktop.
Clone an object in Java
private User testUser;
public User getTestUser() {
Gson gson = new Gson();
return gson.fromJson(gson.toJson(testUser), User.class);
}
@LenarBad
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment