Check out example codes for "resurce leak java". It will help you in understanding the concepts better.

Code Example 1

public void readShapeData() throws IOException {
    Scanner in = new Scanner(;
    try {
        System.out.println("Enter the width of the Rectangle: ");
        width = in.nextDouble();
        System.out.println("Enter the height of the Rectangle: ");
        height = in.nextDouble();
    } finally {

Learn ReactJs, React Native from