一个小问题
import java.Math.BigInteger;
import java.util.*;
public class fac
{
protected static ArrayList table=new Arraylist();
static
{
table.add(BigInteger.valueOf(1));
}
public static synchronized BigInteger fac(int x)
{
if(x<0) throw new IllegalArgumentException("x must be non-negative");
for(int size=table.size();size<=x;size++)
{
BigInteger lastfact=(BigInteger)table.get(size-1);
BigInteger nextfact=lastfact.multiply(BigInteger.table.valueOf(size));
table.add(nextfact);
}
return (BigInteger)table.get(x);
}
public static void main(String[] para)
{
for(int i=0;i<=50;i++)
{
System.out.println(i+"!="+factorial(i));
}
}
}
import java.Math.BigInteger;编译时说包不存在?为什么?难道还要建一个包?这不是java提供的吗?再一个系统为什么总是把math中的M大写?