import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); BigInteger bi1 = new BigInteger(scanner.next()); BigInteger bi2 = new BigInteger(scanner.next()); System.out.println(bi1.multiply(bi2)); } }
import java.util.Scanner; /** * 给定两个数字(0-9)字符串(长度不限)求它们的乘积。 */ public class Test6 { public static int multiplier(int num1,int num2){ int result=num1*num2; return result; } public static void main(String[] args) { System.out.print("请输入第一个数字字符串:"); Scanner scanner1=new Scanner(System.in); String str1=scanner1.nextLine(); System.out.print("请输入第二个数字字符串:"); Scanner scanner2=new Scanner(System.in); String str2=scanner2.nextLine(); int num1=Integer.parseInt(str1); int num2=Integer.parseInt(str2); System.out.println("结果为: "+multiplier(num1,num2)); } }