020-004-006

Collections: Iterating Elements with Iterator

Hard

Problem Description

Collections: Iterating Elements with Iterator

In this problem, you will create a program that traverses an integer list using Iterator, removes elements with values 10 or less, and displays the remaining elements to standard output one per line.

Learning Objective: Understand collection traversal using Iterator

Overview

Iterator is an interface for sequentially accessing collection elements. Use hasNext() to check for next element and next() to retrieve it. Elements can be safely removed during iteration.

Specifications

Create a program to manage an integer list and remove elements based on conditions.

  • First input: Number of elements n to add to list
  • Next n inputs: Integer values to add
  • Traverse all elements using Iterator
  • Remove elements with value 10 or less
  • Output remaining elements in order (one element per line)
  • If no elements remain, output "Empty"

Input Format

<count>
<integer1>
<integer2>
...

Output Format

<remaining element1>
<remaining element2>
...

or

Empty

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up