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

https://www.youtube.com/watch?v=ANuuSFY2BbY&list=PLFE2CE09D83EE3E28&index=7

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

I wrote the following line of code

Scanner bucky = new Scanner(System.in);

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

Replies

Oldest  Newest  Rating
+1 Mathias Frits Rørvik · August 8, 2014
Yeah, you should call bucky.close() to close the scanner.
  • 1

Java / Android Development

107,167 followers
About

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

Links
Moderators
Bucky Roberts Administrator