javabigintegervalue-of

BigInteger valueOf method cannot find symbol


I created an array consisting BigInteger objects. When I want to assign numbers to array, I get a cannot find symbol error. Can you help me? That's the code:

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);

    }
}

Input values are 0 1 5. And this is the error:

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

Solution

  • valueOf is a static method

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