title: Ignore default constructor and use constructor with parameters in Java
body: <p>I am not very well rounded in Java, which is why I am asking this question that is probably very stupid sounding. Nonetheless, I am trying to figure out how to ignore a class's default construct method, and use a construct method with parameters instead. For example, something like this:</p>
  
  <pre><code>public class Name {
  
      String firstName, lastName;
  
      public Name()
      {
          String dialog = JOptionPane.showInputDialog("First and Last name: ");
          Scanner inName = new Scanner(dialog);
          firstName = inName.next();
          lastName = inName.nextLine();
      }
  
      public Name(String newFirst, String newLast)
      {
          firstName = newFirst;
          lastName = newLast;
      }
  
  }
  </code></pre>
  
  <p>I then have a class called Student which extends name as such: </p>
  
  <pre><code>public class Student extends Name
  {
  
      public Student(String firstName, String lastName) 
      {
          firstName = firstName;
          lastName = lastName; 
      }
  
  }
  </code></pre>
  
  <p>So, the first construct method from Name class prompts the user to enter their name, but say I already know the user's name and have it stored in some variables, how can I create a new Student() object (which is really a name() object) without invoking that first default constructor, and instead invoke it as such:</p>
  
  <pre><code>Student student1 = new Student(firstName, lastName);
  </code></pre>
  
  <p>I understand why the following line would call the default construct method:</p>
  
  <pre><code>Student student1 = new Student();
  </code></pre>
  
  <p>But the next following line stil calls the same parameterless construct method, even though I am using parameters:</p>
  
  <pre><code>Student student1 = new Student(firstName, lastName);
  </code></pre>
  
  <p>What am I doing wrong here?</p>