static boolean isHappy ( int n ) {
  HashSet < Integer > s = new HashSet < Integer > ( ) ;
  s . add ( n ) ;
  while ( true ) {
    if ( n == 1 ) return true ;
    n = sumDigitSquare ( n ) ;
    if ( ( s . contains ( n ) && n != ( int ) s . toArray ( ) [ s . size ( ) - 1 ] ) ) return false ;
    s . add ( n ) ;
  }
}

static boolean isHappy ( int n ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; s . add ( n ) ; while ( true ) { if ( n == 1 ) return true ; n = sumDigitSquare ( n ) ; if ( ( s . contains ( n ) && n != ( int ) s . toArray ( ) [ s . size ( ) - 1 ] ) ) return false ; s . add ( n ) ; } }
(method_declaration (modifiers) type: (boolean_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments (type_identifier))) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) (while_statement condition: (parenthesized_expression (true)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) consequence: (return_statement (true))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (binary_expression left: (identifier) right: (cast_expression type: (integral_type) value: (array_access array: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) index: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))))))) consequence: (return_statement (false))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))