Java Reference
In-Depth Information
figure 3.8
Details of the
BigInteger
constructor
BigInteger
public BigInteger (
)
Translates the decimal String representation of a BigInteger into a
BigInteger. The String representation consists of an optional minus
sign followed by a sequence of one or more decimal digits. The
character-to-digit mapping is provided by Character.digit . The String
may not contain any extraneous characters (whitespace, for example).
String val
Parameters:
val - decimal String representation of BigInteger.
Throws:
NumberFormatException - val is not a valid representation of a
BigInteger.
See Also:
Character.digit(char, int)
3.6.1 the this reference
The first use of this is as a reference to the current object. Think of the
this reference as a homing device that, at any instant in time, tells you
where you are. An important use of the this reference is in handling the
special case of self-assignment. An example of this use is a program that
copies one file to another. A normal algorithm begins by truncating the
target file to zero length. If no check is performed to make sure the source
and target file are indeed different, then the source file will be truncated—
hardly a desirable feature. When dealing with two objects, one of which is
written and one of which is read, we first should check for this special
case, which is known as aliasing .
this is a reference
to the current
object. It can be
used to send the
current object, as a
unit, to some other
method.
For a second example, suppose we have a class Account that has a
method finalTransfer . This method moves all the money from one account
into another. In principle, this is an easy routine to write:
Aliasing is a spe-
cial case that
occurs when the
same object
appears in more
than one role.
// Transfer all money from rhs to current account
public void finalTransfer( Account rhs )
{
dollars += rhs.dollars;
rhs.dollars = 0;
}
 
Search WWH ::




Custom Search