Q:

adding two very large numbers

Possible Duplicate:
How to add two numbers of any length in java? 

can anyone help me with this?
what i need to do is to add a very large number that a calculator doesn't hold.
this is the code i have though it can only hold a number until 2147483647.. any number higher than that i get the error message stating "integer number too large"
can anyone tell me how can i use a larger number?
import java.math.BigDecimal;

public class AddTwoBigNumbers{
  public static void main() {
  BigDecimal num1, num2;
  num1 = new BigDecimal(2147483647);
  num2 = new BigDecimal(2147483647);
  Sum(num1, num2);
  }

  public static void Sum(BigDecimal val1, BigDecimal val2){
  BigDecimal sum = val1.add(val2);
  System.out.println("Sum of two BigDecimal numbers: "+ sum);
  }
}

A:

Sounds like you want to use BigInteger

[edit] To pass a number larger than Integer.MAX_VALUE to the constructor, use a long: 
new BigInteger(9876543210L)

If you need a number larger than a long can hold, you'll need to find some other way of constructing it (like passing it in as a string, or multiplying two BigIntegers).

