What about other objects referred to in the elements? How deep do you want your clone?
If your map elements don't have any deep references and/or everything is Serializable
, you can serialize the map via ObjectOutputStream
into a ByteArrayOutputStream
and then deserialize it right away.
The only other alternative is to do it manually.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…