首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

怎样在自己的类里面定义BigInteger类型的属性

2012-03-28 
求助:怎样在自己的类里面定义BigInteger类型的属性我想在Fraction类里面有两个BigInteger类型的属性,下列

求助:怎样在自己的类里面定义BigInteger类型的属性
我想在Fraction类里面有两个BigInteger类型的属性,下列代码应该怎么改:
import java.math.BigInteger;
class Fraction{
public BigInteger numerator,denominator;
public Fraction(){
BigInteger aaaa = new BigInteger(0);
BigInteger bbbb = new BigInteger(1);
this.numerator = aaaa;
this.denominator = bbbb; 
}
}


[解决办法]
哦,是这样的:BigInteger的构造函数是private的,这样写:

this.numerator = BigInteger.valueOf(0);

热点排行