BigInteger.valueOf(long a);
BigInteger的valueOf方法的参数是long类型,你输入的数字应该超过java里long的范围了,而且大数值类BigInteger 一般是通过其构造函数来转换类型的,常用这个:
BigInteger(String val)
Translates the decimal String representation of a BigInteger into a BigInteger.所以你直接写成: BigInteger test=new BigIntege("100000000000000000000");就OK了。注意构造函数的参数是String类型。

解决方案 »

  1.   

    原来如此 感激不尽 顺带请教另一个问题:
    我定义一个long数, long a=9223372036854775807; 9223372036854775807是Long类型的最大值
    但是提示The literal 9223372036854775807 of type int is out of range 这是什么情况~?
      

  2.   

    The literal 9223372036854775807 of type int
    你看错误提示说你这个超过了int范围,它认为你是int,你没定义好吧,仔细检查一下。
      

  3.   

    我直接用long a=9223372036854775807;提示错误
    我用 Long a=new Long("9223372036854775707");就没错了哈,哎,java的构造方法感觉好奇葩~
      

  4.   

    我直接用long a=9223372036854775807;提示错误
    我用 Long a=new Long("9223372036854775707");就没错了哈,哎,java的构造方法感觉好奇葩~
    不是,java里你定义long类型的数在末尾要加“L”。
    long a=9223372036854775807L;  就好了。
     Long a=new Long("9223372036854775707");这个是通过Long的包装类转换而得到的long值:Long(String s)
    Constructs a newly allocated Long object that represents the long value indicated by the String parameter.java的语法比较严格而已,严格有严格的好处。