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

Conteúdo do Curso

Java Extended

Java Extended

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

book
Challenge: Find Maximum and Minimum in Array

Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 8
toggle bottom row

book
Challenge: Find Maximum and Minimum in Array

Tarefa
test

Swipe to show code editor

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 desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 8
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt