We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
参考代码太简单了,比如遇到循环引用对象怎么办?
The text was updated successfully, but these errors were encountered:
嗯,可以把你的答案贡献出来。
Sorry, something went wrong.
/** * This method makes a "deep clone" of any object it is given. * * @param object origin target should implement Serializable */ public static Object deepClone(Object object) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); return ois.readObject(); } catch (Exception e) { e.printStackTrace(); return null; } } }
@nttd-junchu 对的,可以通过序列化实现深复制
No branches or pull requests
参考代码太简单了,比如遇到循环引用对象怎么办?
The text was updated successfully, but these errors were encountered: