I am trying to use a recursive method/function, which uses the Scanner class. Closing the scanner, causes an exception to be thrown the next time the same method is called within the recursion. A workaround to this is not to close the scanner at all, but this is not a right approach. I suspect the same scanner object is used between recursive calls, so that's why closing it creates havoc. If my assumption is correct then closing the scanner in the last method call would be a valid workaround (i.e. no actual resource leak). Is there anything I may be missing before jumping into Scanner and related implementation code? 

**EDIT**

The answers provided were really useful and enlightening. In summary, the problem is the constant re-opening and closing of the scanner, and not recursion per se. The reason I would avoid passing the scanner object as parameter is that this example simulates a larger project, calling multiple recursive functions and I would have to pass the scanner object in all of them.

On the practical side, and from the answers provided, I think just closing the scanner in the last recursive call would work without having any resource leaks. Any related opinions would be welcome, esp. if you see something wrong with my approach.

Here is an example of my initial experiment:

```
package scanner;

import java.util.Scanner;

public class Main {

  public static void acceptValidInput() {

    System.out.print("Enter a number greater than 10: ");
    Scanner sc = new Scanner(System.in);
    int i = sc.nextInt();

    // Adding this will make an exception to be thrown:
    sc.close();

    if (i <= 10) {
        acceptValidInput();
    }
}

  public static void main(String[] args) {
    acceptValidInput();
    System.out.println("Your input is valid");
  }
}

```