```
public class Solution {
public boolean isHappy(int n) {
int sum = n;
while(sum != 1) {
if(sum == 4 || sum == 0) return false;
sum = getSum(sum);
}
return true;
}
public static int getSum(int n) {
int sum = 0;
while(n > 0) {
sum += (n%10)*(n%10);
n /= 10;
}
return sum;
}
}
```