【问题标题】:BigInteger valueOf method cannot find symbolBigInteger valueOf 方法找不到符号
【发布时间】:2016-09-07 14:12:57
【问题描述】:

我创建了一个包含 BigInteger 对象的数组。当我想为数组分配数字时,我得到一个找不到符号错误。你能帮助我吗?代码如下:

import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Solution
{
    public static void main(String[] args) 
    {
        Scanner in = new Scanner(System.in);
        int t1= in.nextInt();
        int t2= in.nextInt();
        int n= in.nextInt();

        BigInteger[] arr = new BigInteger[n];
        arr[0] = new BigInteger.valueOf(t1);
        arr[1] = new BigInteger.valueOf(t2);

    }
}

输入值为 0 1 5。 这是错误:

Solution.java:15: error: cannot find symbol
        arr[0] = new BigInteger.valueOf(t1);
                               ^
  symbol:   class valueOf
  location: class BigInteger
Solution.java:16: error: cannot find symbol
        arr[1] = new BigInteger.valueOf(t2);
                               ^
  symbol:   class valueOf
  location: class BigInteger
2 errors

【问题讨论】:

    标签: java biginteger value-of


    【解决方案1】:

    valueOf 是一个静态方法

    arr[0] = BigInteger.valueOf(t1);
    

    【讨论】:

      猜你喜欢
      • 2015-01-19
      • 2019-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多