Resource leak. bucky is never closed >> Java video 6

0 Ric BasicJava · December 1, 2014

import java.util.Scanner;
public class paku {

    public static void main(String[] args) {
        Scanner bucky = new Scanner(System.in);
        
        
        
        System.out.println(bucky.nextLine());
        bucky.close();

    }

}



I hah put >>>> bucky.close();

but the Console never show (console can't run)....

please help me.

Post a Reply

Replies

Oldest  Newest  Rating
0 Developer John · February 17, 2015
Teemmy Ellorry, have you resolved your problem?:dizzy:
0 Ric BasicJava · December 2, 2014
resolved .... by my self thanks
0 Developer John · December 2, 2014
I know right, when I was experimenting with JOptionPane, I received a strange error when nothing was wrong with the code.. I was like, wtf m8!?:sideways:
0 Siem Sium · April 23, 2017
Hey Guys!
If your gettting the "Resource Leak" error, then here's how you fix it.

Close the method at the end. (Like in the picture, call out[type out] your scanner.
I built a little Kindegarden Calculator:
public static void main(String args[]){
Scanner Calculator = new Scanner(System.in);
double Number1, Number2, answer;
System.out.println("Enter Your First Number: ");
Number1 = Calculator.nextDouble();
System.out.println("Now Your Second Number: ");
Number2 = Calculator.nextDouble();
answer = Number1 + Number2;
System.out.println(answer);
Calculator.close();
}
}

And when you hit play, your "leak" should be resolved.

Hope this helps!
0 Teemmy Ellorry · February 16, 2015
Please what's the solution? Am having the same problem...
  • 1

Java / Android Development

129,851 followers
About

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

Links
Moderators
Bucky Roberts Administrator