static int maxPrimeSubarray ( int arr [ ] , int n ) {
  int max_ele = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ;
  boolean prime [ ] = new boolean [ max_ele + 1 ] ;
  Arrays . fill ( prime , true ) ;
  SieveOfEratosthenes ( prime , max_ele ) ;
  int current_max = 0 , max_so_far = 0 ;
  for ( int i = 0 ;
  i < n ;
  i ++ ) {
    if ( prime [ arr [ i ] ] == false ) current_max = 0 ;
    else {
      current_max ++ ;
      max_so_far = Math . max ( current_max , max_so_far ) ;
    }
  }
  return max_so_far ;
}

static int maxPrimeSubarray ( int arr [ ] , int n ) { int max_ele = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; boolean prime [ ] = new boolean [ max_ele + 1 ] ; Arrays . fill ( prime , true ) ; SieveOfEratosthenes ( prime , max_ele ) ; int current_max = 0 , max_so_far = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] == false ) current_max = 0 ; else { current_max ++ ; max_so_far = Math . max ( current_max , max_so_far ) ; } } return max_so_far ; }
(method_declaration (modifiers) type: (integral_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (integral_type) name: (identifier) dimensions: (dimensions)) (formal_parameter type: (integral_type) name: (identifier))) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list)))) (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) (true)))) (expression_statement (method_invocation name: (identifier) arguments: (argument_list (identifier) (identifier)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (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: (identifier)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (identifier) index: (array_access array: (identifier) index: (identifier))) right: (false))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal))) alternative: (block (expression_statement (update_expression (identifier))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier) (identifier))))))))) (return_statement (identifier))))