title: Input on console doesn't work with this java program - why?
body: <p>With this program it skips past the inputs - and outputs this to the console: </p>
  
  <pre><code>    C:\Users\User\workspace\ClassManager\bin&gt;java AccessPupilData
  What would you like to do?
  l = list pupils -------- a = add pupil ---------
  a
  a
  You want to add a pupil.
  Enter your first name:
  Enter your surname:
  Firstname :null
  Surname: null
  Age :0
  You created a pupil called null null who is aged 0
  </code></pre>
  
  <p>(I'm using a dos prompt to run the program in, not the eclipse console). <strong>Why don't I get to input when the scanner is called?</strong></p>
  
  <p>First the initial class that kicks off everything:</p>
  
  <p></p>
  
  <pre><code>public class AccessPupilData {
  
  public static void main (String arguments[]){
  </code></pre>
  
  <p>...</p>
  
  <pre><code>case 'a': Pupil pupil = new Pupil(); break;
  </code></pre>
  
  <p></p>
  
  <p>And then the Pupil class that is where I want to collect all the information: </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Pupil {
      private String surname;
      private String firstname;
      private int age;
  
  public Pupil(){
  
      Scanner in = new Scanner(System.in);
  
  
         // Reads a single line from the console 
         // and stores into name variable
         System.out.println("Enter your first name: ");
         if(in.hasNext()){
             this.firstname = in.nextLine();
         }
  
         System.out.println("Enter your surname: ");
         if(in.hasNext()){
             this.surname = in.nextLine();
         }
         // Reads a integer from the console
         // and stores into age variable
         if(in.hasNext()){ 
         System.out.println("Enter your age: ");
         this.age=in.nextInt();
         }
         in.close();            
  
         // Prints name and age to the console
  
         System.out.println("Firstname :" +firstname);
         System.out.println("Surname: " + surname);
         System.out.println("Age :"+ age);
  
  
      System.out.print("You created a pupil called " + this.firstname + " " + this.surname + " who is aged " + this.age);
  }
  </code></pre>
  
  <p>}</p>