Here is an accepted iterative solution that uses constant space.

```
public class Solution {
public boolean isHappy(int n) {
if(n <= 0) {
return false;
} else if(n == 1) {
return true;
}
int number = sumOfSquare(n);
while(number >= 10) {
number = sumOfSquare(number);
}
return number == 1 || number == 7;
}
private int sumOfSquare(int n) {
int digit;
int sum = 0;
while(n > 0) {
digit = n % 10;
n /= 10;
sum += digit * digit;
}
return sum;
}
}
```