After observation of several numbers' output, you will find that there is a pattern that all numbers after calculated will converge to either 1 or 4 eventually, and the implementation of this idea is as followed

```
public boolean isHappy(int n) {
int sum = n;
while(n != 1 && n != 4){
sum = 0;
while(n>0){
sum += (n%10)*(n%10);
n /= 10;
}
n = sum;
}
return sum==1;
}
```