Not exactly an error. The compiler just warns you that you have an unused variable.
You might want to close that Scanner
instance at the end of your code. I don’t think it’s a pressing issue since that instance is using System.in
, but for other I/O operations (like reading files), it’s important to close them afterwards. I haven’t done Java in a long time, so I don’t know how to close it.