Java中String类与Integer类的几个方法

计算诸如-123,456,789 + 123,123的值


import java.math.BigInteger;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		String str1, str2;
		BigInteger a, b;
		while(cin.hasNext()){
			str1 = cin.next();
			str2 = cin.next();
			str1 = str1.replaceAll(",", "");
			str2 = str2.replaceAll(",", "");
			a = new BigInteger(str1);
			b = new BigInteger(str2);
			System.out.println(a.add(b));
		}
	}
}


Java中String类与Integer类的几个方法,布布扣,bubuko.com

Java中String类与Integer类的几个方法

上一篇:java Swing 之列表框控件


下一篇:C++ string中的几个小陷阱,你掉进过吗?