Kotlinlearncs.online LogoJava
Return to List

Solve: Print Range of Array

Created By: Justin Maier
/ Version: 2024.7.0

You are given three variables: a nonempty array of ints named nums, and two int variables first and last. Both first and last are valid indices for the nums array and first is no larger than last.

Print out the elements of nums from the index first to the index last (inclusive), placing each element on their own line.

For example, if nums is the array {1, 4, 6, 2, 8}, first is 1, and last is 3, you should print out the values 4, 6, and 2, in that order.

Related Lessons

Stuck? You may find these lessons helpful: