title: Reading a text file with boolean values into an array list as objects
body: <p>I am trying to read a file of string int and boolean values into an array list as object blocks. The string values go into the array list just fine, its the boolean values I'm having trouble with. Every time I encounter the variable 'active'there is a mismatch exception. Please help! The text file for if the block is a wizard goes in this order
  name (string)
  location (string)
  active (boolean) ... the one I'm having issues with
  skill level (int)
  friendliness (int)</p>
  
  <p>I included the driver class as well as the Witch class which contains the 
  variable 'active' originally.</p>
  
  <p><a href="https://i.stack.imgur.com/nty9a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nty9a.png" alt="enter image description here"></a></p>
  
  <pre><code><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Driver class that adds objects to the array list based on what the scanner 
  reads from the file
      package project2;
  
      import java.util.Scanner;
      import java.io.File;
      import java.io.FileNotFoundException;
      import java.util.ArrayList;
  
      public class Project2 {
  
        public static void main(String[] args) {
  
          Scanner inputFileScanner1 = null;
  
          //file name
          String listFile = "list.txt";
  
          // Check to see if file exists
          try {
            inputFileScanner1 = new Scanner(new File(listFile));
  
          } catch (FileNotFoundException e) {
  
            System.out.println("Error opening file.");
            System.exit(1);
          }
  
          //create Individuals arraylist and Location arraylist
          ArrayList &lt; Individual &gt; Individual = new ArrayList &lt; &gt; ();
          ArrayList &lt; String &gt; Location = new ArrayList &lt; &gt; ();
  
          //declare variables to read file contents into the arraylist
          String wizName, witchName, individualName, location, position, 
  
          profession = null, line = null;
          int wizLevel, witchSkillLevel, friendliness;
          boolean active;
  
          //while there is a next line, if the line equals Wizard, the next                                        four lines
          // are wizard name, location, position and level
          while (inputFileScanner1.hasNext()) {
            line = inputFileScanner1.nextLine();
            if (line.trim().equals("Wizard")) {
  
              wizName = inputFileScanner1.nextLine().trim();
              location = inputFileScanner1.nextLine().trim();
              position = inputFileScanner1.nextLine().trim();
              wizLevel = inputFileScanner1.nextInt();
  
              //create wizard object
              Individual wizard = new Wizard(wizName, location, position, profession, wizLevel);
  
              //fill arraylist with wizard objects
              Individual.add(wizard);
              Location.add(location);
  
            } //if the next line is Witch, the next five lines are
            // witch name, location, yes/no active, skill level, and friendliness
            //in that order
            else if (line.trim().equals("Witch")) {
              witchName = inputFileScanner1.nextLine().trim();
              location = inputFileScanner1.nextLine().trim();
              active = inputFileScanner1.nextBoolean();
              witchSkillLevel = inputFileScanner1.nextInt();
              friendliness = inputFileScanner1.nextInt();
  
              //create witch object
              Individual witch = new Witch(witchName, location, profession, witchSkillLevel, friendliness, active);
  
              //fill the arraylist with witch objects
              Individual.add(witch);
              Location.add(location);
            } else {
  
              profession = line.trim();
              individualName = inputFileScanner1.nextLine().trim();
              location = inputFileScanner1.nextLine().trim();
  
              Individual i = new Individual(profession, individualName, location);
  
              Individual.add(i);
              Location.add(location);
            }
            java.util.Collections.sort(Individual);
            java.util.Collections.sort(Location);
  
          }
  
          System.out.println("List of friends and possible allies: " + Location);
  
          inputFileScanner1.close();
  
        }
  
      }</code></pre>
  </div>
  </div>
  
  </code></pre>
  
  
  
  <p>//Witch class which holds values that are in the text file. active is the boolean value Im having trouble with
      package project2;</p>
  
  <pre><code> public class Witch extends Individual implements Magical {
  
        private int skill;
        private int friendly;
  
            //Constructor with witch parameters
        public Witch(String name, String location, String profession,
          int skill, int friendly, boolean active) {
  
        }
  
        //default constructor
        public Witch() {
  
        this("", "", "", 0, 0, false);
        }
  
        //overridden abstract method from magical interface 
        @Override
        public void assess() {
          System.out.print(this.friendly + " " + this.skill + " " + super.toString());
        }
      }
  
  &lt;!-- end snippet --&gt;
  </code></pre>
  
  <p>Text file :
  <a href="https://i.stack.imgur.com/s6MBZ.png" rel="nofollow noreferrer">enter image description here</a></p>