BigInteger.ONE

A

au714

Why does the BigInteger class have a few pre-defined static constants,
as in ZERO, ONE, and TEN?

Seems very arbitrary. What is the reasoning behind this in the first
place?


FGB
 
S

Stefan Schulz

BigIntegers are immutable, therefore it makes sense to share some
common instances.

Traditionally, these three numbers crop up rather frequently, so
offering "shorthand" instances for them makes sense. Even more if you
consider the "static import" feature of java 1.5 - setBase(TEN) is much
clearer then setBase(new BigInteger(10))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top