```
public static boolean isHappy(int n) {
int sum = 2, old;
final boolean[] map = new boolean[730];
while (sum > 1) {
if (map[sum]) return false;
map[sum] = true;
sum = 0;
while (n > 0) {
old = n;
n /= 10;
old -= n * 10;
sum += old * old;
}
n = sum;
}
return sum == 1;
```

}

Why 730?

We got integer value input, then max possibly point is (9^2+9^2+9^2+9^2+9^2+9^2+9^2+9^2+9^2) 729.