2016-09-07 77 views
-2

我創建了一個由BigInteger對象組成的數組。當我想將數字賦給數組時,我得到一個找不到符號的錯誤。你可以幫我嗎?這是代碼:BigInteger valueOf方法找不到符號

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 

回答

7

valueOf是一個靜態方法

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