0

enter image description here

sc function is never closed. What to do to avoid this error?

I tried to input integer data using scanner function in java, but the sc line is facing some error. Although the code runs properly. But I want to know why it showing error. Thanks in advance.

  • Does this answer your question? [Scanner is never closed](https://stackoverflow.com/questions/15613626/scanner-is-never-closed) – Melron Nov 09 '22 at 07:05
  • Generally, for a `Scanner` wrapping `System.in`, this should be considered a false positive. If you close `sc`, you will also close `System.in`, which means you can no longer use it for any user input. – Mark Rotteveel Nov 09 '22 at 08:32

0 Answers0