我有一个int,范围从0-99
。我需要得到两个单独的整数,每个整数都包含一个数字。我无法弄清楚如何得到第二位数字。 (从64
如何获得6
)这是我的代码:从int获得第二个数字
public int getNumber(int pos, boolean index){//if index = 1 - first digit, if index = 0 - second digit
int n;
if(index){
n = pos%10;
}else{
if(pos<10){
n=0;
}else{
//????
}
}
return n;
}
你也将需要初始化n的INT N = 0; ...它不是答案的一部分,但会有所帮助 – Akshay