Maybe I’m really confused because it seems a very simple question but Google and the official documentation were not enough.
I want to copy an BigInteger, and I can’t find a clean way of doing it. BigInteger a = b when b is a BigInteger, as BigInteger is an object and there’s no operator overloading here, a references to the same object as b
The cleanest way I’ve found so far is BigInteger a = b.add(BigInteger.ZERO), but still a dirty way for me.
BigIntegeris immutable like other wrapper classes such asIntegerandString. So no worries about possible alteration/tampering.P.S: As a bonus, here’s a link on when defensive copying is needed.
http://www.javapractices.com/topic/TopicAction.do?Id=15