Here is my solution:

```
public boolean isHappy(int n) {
HashSet<Integer> numbers = new HashSet<Integer>();
while(n!=1){
if(!numbers.add(n)){
return false;
}else{
int tmp = 0;
while(n!=0){
int digit = n%10;
tmp += digit * digit;
n/=10;
}
n = tmp;
}
}
return true;
}
```