I changed your method to this, then it gives the requested result:
public int compute(int methParam) {
int sum = 0;
for (int i = 0; methParam > 10; i++) {
int currentDigit = methParam % 10;
methParam = methParam / 10;
sum = sum + currentDigit;
}
if (sum + methParam > 10) {
return compute(sum + methParam);
} else {
return sum + methParam;
}
}
Please note that i moved the declaration of sum inside the method, instead of making it a field.