
Is there any simple method of string multiplication in java ..?

public class StringMultiplication {
public static void main(String[] args) {
String number1 = "17";
String number2 = "15";
char[] n1 = number1.toCharArray();
char[] n2 = number2.toCharArray();
int result = 0;
for (int i = 0; i < n1.length; i++) {
for (int j = 0; j < n2.length; j++) {
result += (n1[i] - '0') * (n2[j] - '0')* (int) Math.pow(10, n1.length * 2 - (i + j + 2));
}
}
System.out.println(result);
}
}

import java.math.*;
public class StringMultiplication {
public static void main(String[] args) {
String number1 = "17";
String number2 = "15";
BigInteger num1=new BigInteger(number1);
BigInteger num2=new BigInteger(number2);
BigInteger result=num1.multiply(num2);
System.out.println(result);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.