Conteúdo do Curso
Java Extended
Java Extended
Challenge: Find Maximum and Minimum in Array
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.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Obrigado pelo seu feedback!
Challenge: Find Maximum and Minimum in Array
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.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Obrigado pelo seu feedback!
Challenge: Find Maximum and Minimum in Array
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.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.
Obrigado pelo seu feedback!
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.
- In the
findMax
method, initialize themax
variable with the first element of the array. - In the for loop, compare the current element with
max
. - If the current element is greater, update
max
with the current element. - Return the value of the
max
variable. - In the
findMin
method, initialize themin
variable with the first element of the array. - In the for loop, compare the current element with
min
. - If the current element is smaller, update
min
with the current element. - Return the value of the
min
variable. - In the
main
method, call thefindMax
method with the correct parameter, pass thenumbers
array into it, and assign the result to themax
variable. - In the
main
method, call thefindMin
method with the correct parameter, pass thenumbers
array into it, and assign the result to themin
variable.