Resource is never closed!

0 Shamal Sandeep · August 8, 2014
Hi, I'm beginner in Java. I thought It will be great If I get started with bucky so Just watched his Java tutorials but in this video

Video number 7 - Java Programming Tutorial - 7 - Building a Basic Calculator

I wrote the following line of code

Scanner bucky = new Scanner(;

and get a warning - Resource leak: 'bucky' is never closed (I'm not sure whether it's an error, warning or an exception) But the program works. And bucky does not get that message ? Why's that ?

Post a Reply


Oldest  Newest  Rating
+1 H. P. Lovecraft · August 8, 2014
Yeah, you should call bucky.close() to close the scanner.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator