Numbers filter

Report a typo

Write a class with the name NumbersFilter that extends the Thread class and overrides the method run. It should read integer numbers from the standard input (line by line). If the number is even, the worker must print it to the standard output (each number on a new line), if a number is 0, the worker must stop.

Use the provided template for your class.


The testing system will start your class as a regular thread.

Sample Input 1:

1
2
3
4
0

Sample Output 1:

2
4
Write a program in Java 17
import java.util.Scanner;

class NumbersFilter extends Thread {

/* use it to read numbers from the standard input */
private final Scanner scanner = new Scanner(System.in);

@Override
public void run() {
// implement this method
}
}
___

Create a free account to access the full topic