统计数字,这个程序有什么问题吗?求大神
public class Solution {
int y=1;
int x;
int num;
int z;
int r;
public int digitCounts(int k, int n) {
int[] j = new int[n+1];
for(int p=0;p<n+1;p++) {
j[p]=p;
}
for (;r<n+1;){
if (x<Math.pow(10,y)) {
for (int o = 0; o <y; o++) {
z = j[x] / ((int) Math.pow(10, o)) % 10;
if (k == z) {
num++;
}
}
x++;
r++;
}
else{y++;}
}
return num;
}
}