Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Sorting Even Numbers Challenge | Methods
Java Extended

Sorting Even Numbers ChallengeSorting Even Numbers Challenge

Завдання

Your task is to write a method to sort an integer array in such a way that it contains only even values (even numbers are those that are divisible by 2 without a remainder). After that, in the main method, you need to print them to the console. I've already written a method for displaying the array on the screen, so don't worry about it.

This task is a great opportunity to learn a new operator. The % operator returns the remainder of a division operation. For example, 5 % 2 = 1. This is because 5 does not divide evenly by 2, so when we divide 5 by 2, we have a remainder of 1. You can use this operator in the task to check if a number is even. Use the if syntax: if (element % 2 == 0) - this expression will check if the number is even and return true or false.

Все було зрозуміло?

Секція 2. Розділ 8
toggle bottom row

Sorting Even Numbers ChallengeSorting Even Numbers Challenge

Завдання

Your task is to write a method to sort an integer array in such a way that it contains only even values (even numbers are those that are divisible by 2 without a remainder). After that, in the main method, you need to print them to the console. I've already written a method for displaying the array on the screen, so don't worry about it.

This task is a great opportunity to learn a new operator. The % operator returns the remainder of a division operation. For example, 5 % 2 = 1. This is because 5 does not divide evenly by 2, so when we divide 5 by 2, we have a remainder of 1. You can use this operator in the task to check if a number is even. Use the if syntax: if (element % 2 == 0) - this expression will check if the number is even and return true or false.

Все було зрозуміло?

Секція 2. Розділ 8
toggle bottom row
some-alt