java - Split a Integer every 3rd position and make operations with those numbers?



For example. I have the Integer=45859694, and I need to split it on this way from left to right 458,596,94 and mupltiply the first number by 7, the second number by 3 and the third number by 1

2 Answers: 

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)
    tempVal = value.substring(index,index+3);
    //do my operation on Integer.parseInt(tempVal)
    index +=3;

or String.valueof if it isnt an Integer object


Obtain the string representation of the integer (String.valueOf), then convert to an array and process the groups of three elements in the array. And you're home!