Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Find Maximum and Minimum in Array Challenge | Methods
Java Extended
course content

Course Content

Java Extended

Java Extended

1. Deep Java Structure
2. Methods
3. String Advanced
4. Classes
5. Classes Advanced

bookFind Maximum and Minimum in Array Challenge

Task

Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.

  1. In the findMax method, initialize the max variable with the first element of the array.
  2. In the for loop, compare the current element with max.
  3. If the current element is greater, update max with the current element.
  4. Return the value of the max variable.
  5. In the findMin method, initialize the min variable with the first element of the array.
  6. In the for loop, compare the current element with min.
  7. If the current element is smaller, update min with the current element.
  8. Return the value of the min variable.
  9. In the main method, call the findMax method with the correct parameter, pass the numbers array into it, and assign the result to the max variable.
  10. In the main method, call the findMin method with the correct parameter, pass the numbers array into it, and assign the result to the min variable.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 8
toggle bottom row

bookFind Maximum and Minimum in Array Challenge

Task

Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.

  1. In the findMax method, initialize the max variable with the first element of the array.
  2. In the for loop, compare the current element with max.
  3. If the current element is greater, update max with the current element.
  4. Return the value of the max variable.
  5. In the findMin method, initialize the min variable with the first element of the array.
  6. In the for loop, compare the current element with min.
  7. If the current element is smaller, update min with the current element.
  8. Return the value of the min variable.
  9. In the main method, call the findMax method with the correct parameter, pass the numbers array into it, and assign the result to the max variable.
  10. In the main method, call the findMin method with the correct parameter, pass the numbers array into it, and assign the result to the min variable.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 8
toggle bottom row

bookFind Maximum and Minimum in Array Challenge

Task

Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.

  1. In the findMax method, initialize the max variable with the first element of the array.
  2. In the for loop, compare the current element with max.
  3. If the current element is greater, update max with the current element.
  4. Return the value of the max variable.
  5. In the findMin method, initialize the min variable with the first element of the array.
  6. In the for loop, compare the current element with min.
  7. If the current element is smaller, update min with the current element.
  8. Return the value of the min variable.
  9. In the main method, call the findMax method with the correct parameter, pass the numbers array into it, and assign the result to the max variable.
  10. In the main method, call the findMin method with the correct parameter, pass the numbers array into it, and assign the result to the min variable.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Task

Your task is to write two methods: one to find the maximum value and one to find the minimum value in the array.

  1. In the findMax method, initialize the max variable with the first element of the array.
  2. In the for loop, compare the current element with max.
  3. If the current element is greater, update max with the current element.
  4. Return the value of the max variable.
  5. In the findMin method, initialize the min variable with the first element of the array.
  6. In the for loop, compare the current element with min.
  7. If the current element is smaller, update min with the current element.
  8. Return the value of the min variable.
  9. In the main method, call the findMax method with the correct parameter, pass the numbers array into it, and assign the result to the max variable.
  10. In the main method, call the findMin method with the correct parameter, pass the numbers array into it, and assign the result to the min variable.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 8
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt