This week's book giveaway is in the Design forum. We're giving away four copies of Building Microservices and have Sam Newman on-line! See this thread for details.

Hi. I'm trying to use BigIntegers (I need them, normal Integers aren't enough) and multiply two BigIntegers but I get just errors. Also, I'm not really so sure about creating BigInteger values, so if I have something wrong, could you please tell me what I'm doing wrong. So here is my problematic code: ---------------------------------------------------------------------------

public static void main(String[] args) { Scanner nappaimisto; nappaimisto = new Scanner (System.in);

System.out.println("Anna luku 1:"); BigInteger luku1 = new BigInteger(nappaimisto.nextBigInteger()); System.out.println("Anna luku 2:"); BigInteger luku2 = new BigInteger(nappaimisto.nextBigInteger()); BigInteger tulo = new BigInteger.multiply(luku1, luku2); System.out.println("Lukujen " + luku1 + " ja" + luku2 + " tulo on " + tulo); } ---------------------------------------------------------------------------

I'm getting these errors:

--------------------------------------------------------------------------- Kertolasku.java:32: cannot find symbol symbol : constructor BigInteger(java.math.BigInteger) location: class java.math.BigInteger BigInteger luku1 = new BigInteger(nappaimisto.nextBigInteger()); ^ Kertolasku.java:34: cannot find symbol symbol : constructor BigInteger(java.math.BigInteger) location: class java.math.BigInteger BigInteger luku2 = new BigInteger(nappaimisto.nextBigInteger()); ^ Kertolasku.java:35: cannot find symbol symbol : class multiply location: class java.math.BigInteger BigInteger tulo = new BigInteger.multiply(luku1, luku2); ^ 3 errors ---------------------------------------------------------------------------

I've imported Scanner and BigInteger classes. I have also tried to read Java API etc. but this problem doesn't seem to solve just with my skills.

cannot find symbol symbol : constructor BigInteger(java.math.BigInteger)

...is telling you that there is no BigInteger constructor that takes a BigInteger as an argument. (In fact, if you already have a BigInteger...?)

cannot find symbol symbol : class multiply location: class java.math.BigInteger BigInteger tulo = new BigInteger.multiply(luku1, luku2);

...is telling you that you cannot call the multiply method from the classBigInteger. This is because multiply is an instance method -- not a static method. So you need to call multiply on an instance of BigInteger. Also, multiply takes only one argument, which is the BigInteger that the instance is to be multiplied by. For example...