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
course content

Course Content

Java Extended

Java Extended

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

bookSorting Even Numbers Challenge

Task

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.

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

bookSorting Even Numbers Challenge

Task

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.

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

bookSorting Even Numbers Challenge

Task

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.

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 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.

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