title: Using BigIntegers as a condition in while loop in Java
body: <p>I want to use a big integer value in my while loop condition but this is not working.</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.StringTokenizer;
  public class NiceProbelm2 {
  public static void main(String[]args){
      Scanner input = new Scanner(System.in);
      String number = input.nextLine();
      StringTokenizer st = new StringTokenizer(number);
      BigInteger base = null;
      int power=0;
      while (st.hasMoreTokens()) {
            String token1 = st.nextToken();
            String token2 = st.nextToken();
            base = new BigInteger(token1);
            power = Integer.parseInt(token2);
  
  
          }
  
          BigInteger result = base.pow(power);
          //long fresult = (long)result;
          BigInteger div = new BigInteger("10");
          System.out.println(result);
          BigInteger sum=null;
       //NOt working while(result.compareTo(new BigInteger("0")) &gt; 10 )
                      {
          BigInteger digit = result.mod(div);
          result = result.divide(div);
          sum = sum.add(digit);
  
      }
       System.out.println(sum);
  }
  </code></pre>
  
  <p>}</p>