I'm new to java (like a few weeks new), but coming from a C++ background..

This is going to sound retarded, but... can someone explain to me how I can make a BigInteger object to make it have the same value as another BigInteger object? That is they have to have the same value but be two different objects.. like a copy-constructor maybe??

And if I can't, due to the fact that java frowns on copy constructors, then why am I able to half-assedly get around this by doing something like
BigInteger foo = bar.add(BigInteger.ZERO);
where bar is another BigInteger

Thanks a lot, I've been able to find no info besides implementing Cloneable for my own classes.. this all seems really weird to me..

Recommended Answers

All 4 Replies

Just wondering... why do you want to do this? The BigInteger class is immutable, so two instances sharing memory will never be a problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.