java.util.NoSuchElementException No Such Element Exception
<p>New to Java - just trying to get a handle on it. The program is executing as follows:</p>

<pre><code>What's your age?23
23
What's your name?Exception in thread "main" java.util.NoSuchElementException
    at java.util.Scanner.throwFor(Unknown Source)
    at java.util.Scanner.next(Unknown Source)
    at king.getName(king.java:25)
    at king.main(king.java:9)
</code></pre>

<p>The code it is trying to run is below:</p>

<pre><code>import java.util.*;

public class king {



    public static void main(String[] args){
        System.out.println(getAge());
        System.out.println(getName());
    }

    public static int getAge(){
        System.out.print("What's your age?");
        Scanner scanner = new Scanner(System.in);
        String age = scanner.next();
        scanner.close();
        int numberAge = Integer.parseInt(age);
        return numberAge;

    }

    public static String getName(){
        System.out.print("What's your name?");
        Scanner newScanner = new Scanner(System.in);
        String name = newScanner.next();
        newScanner.close();
        return name;
    }

}
</code></pre>
