static int maxDigitInPrimes ( int L , int R ) {
  boolean prime [ ] = new boolean [ R + 1 ] ;
  Arrays . fill ( prime , false ) ;
  sieve ( prime , R ) ;
  int freq [ ] = new int [ 10 ] ;
  int val ;
  for ( int i = L ;
  i <= R ;
  i ++ ) {
    if ( ! prime [ i ] ) {
      int p = i ;
      while ( p > 0 ) {
        freq [ p % 10 ] ++ ;
        p /= 10 ;
      }
    }
  }
  int max = freq [ 0 ] , ans = 0 ;
  for ( int j = 1 ;
  j < 10 ;
  j ++ ) {
    if ( max <= freq [ j ] ) {
      max = freq [ j ] ;
      ans = j ;
    }
  }
  return ans ;
}

static int maxDigitInPrimes ( int L , int R ) { boolean prime [ ] = new boolean [ R + 1 ] ; Arrays . fill ( prime , false ) ; sieve ( prime , R ) ; int freq [ ] = new int [ 10 ] ; int val ; for ( int i = L ; i <= R ; i ++ ) { if ( ! prime [ i ] ) { int p = i ; while ( p > 0 ) { freq [ p % 10 ] ++ ; p /= 10 ; } } } int max = freq [ 0 ] , ans = 0 ; for ( int j = 1 ; j < 10 ; j ++ ) { if ( max <= freq [ j ] ) { max = freq [ j ] ; ans = j ; } } return ans ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (boolean_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (boolean_type) dimensions: (dimensions_expr (binary_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (false)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) dimensions: (dimensions) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (decimal_integer_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (unary_expression operand: (array_access array: (identifier) index: (identifier)))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (identifier))) (while_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (decimal_integer_literal))) body: (block (expression_statement (update_expression (array_access array: (identifier) index: (binary_expression left: (identifier) right: (decimal_integer_literal))))) (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))))))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (decimal_integer_literal))) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (array_access array: (identifier) index: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (identifier))))))) (return_statement (identifier))))