004-009-006

Array and Method: Maximum Value Search

Medium

Problem Description

Array and Method: Maximum Value Search

Learning Objective: Create a method that receives an array as argument and functionalize array operations

Overview

Create a method findMax that receives an integer array as argument and returns the maximum value in the array.

Specifications

  • Method name: findMax
  • Parameter: integer array int[] numbers
  • Return value: maximum value in array (int type)
  • Test with array {34, 78, 12, 89, 45, 67} in main method and output maximum value

Output Format

Maximum value: 89

Hint: Use the first element as initial value and compare with all elements.

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?