。 我有整数= 45859694,我需要通过7将其分割上这种方式从左至右 458,596,94和mupltiply所述第一数目,通过3所述第二数目,并通过1每隔3个位置拆分一个Integer并使用这些数字进行操作?例如,
-1
A
回答
1
String value =Integer.toString();
String tempVal;
int index = 0;
while (index<value.size()){
if (index+3>value.size(){
tempVal = value.substring(index);
//do my operation on Integer.parseInt(tempVal)
break;
}
tempVal = value.substring(index,index+3);
//do my operation on Integer.parseInt(tempVal)
index +=3;
}
或将String.valueOf如果它不是一个Integer对象
+0
非常感谢很多很有帮助 – user2084446 2013-03-07 20:04:59
+0
哈哈得到了接受,我甚至没有输入正确的,很好地编辑它,以适应真正的答案 – 75inchpianist 2013-03-08 01:19:10
0
第三数目获取整数的字符串表示(String.valueOf
),然后转换为数组并处理数组中的三个元素的组。 你回来了!
听起来像是一门功课.. http://whathaveyoutried.com – Sednus 2013-03-07 19:52:05
我需要生成一个银行的参考,他们只是给步骤 – user2084446 2013-03-07 19:56:27