public class BigDataAddUtils {
public static String add(String... params) {
int maxLeng = 0;
// 获取最大长度
for (String s : params) {
if (s.length() > maxLeng)
maxLeng = s.length();
}
StringBuffer result = new StringBuffer();
// 进位 数
int high = 0;
// 将每个待加参数每一位相加 进位
for (int i = 0; i < maxLeng; i++) {
int charInt = 0;
for (String s : params) {
// 高位不够用0代替
charInt += s.length() - 1 < i ? 0 : Integer.parseInt(s.charAt(s.length() - 1 - i) + "");
}
charInt += high;
// 进位
high = charInt / 10;
// 当前位的值 为charInt 余数
int remainder = charInt % 10;
result.append(remainder);
}
// 最后一次进位
if (high > 0) {
result.append(high);
}
// 反转 输出结果
return result.reverse().toString();
}
public static void main(String[] args) {
String aa="100000";
String bb="100";
String cc="1";
System.out.print(add(aa, bb, cc));
}
}