0

As a new OOP programmer, our instructor has faced us with an interesting question. *Why we can't inherent a Scanner class?" He said.

At first it was kinda obvious, "Because it is declared as final!" We said.

He said: "Ok.. Why is the Scanner class defined as final, while PrintWriter is not? and by the way it is not because of security reasons. look it up!"?

What a great question in my sight! they are very similar, we use the first one to scan & input and the second one to write & output.

I've already seen some other similar question in stack overflow, here. But I wasn't satisfied with the answers.


So my question is "Why is the Scanner class is defined as final, while PrintWriter is not?".

I tried to search it in google, found no answer. Matter of fact, found no body asking the same question.

I also looked the Scanner & PrintWriter java documentation. found nothing that justifies it.

  • This thread might help: https://stackoverflow.com/questions/3776940/why-is-the-java-util-scanner-class-declared-final – thorin9000 Jan 30 '23 at 18:47

0 Answers0