title: Can't get my String switch statement to hit anything but default
body: <p>I am trying to use a switch statement to pass a LinkedHashMap to the correct class constructor for a school project(I just added the rest of the code).</p>
  
  <p>The code reads takes in a txt file and based off the first word in the text sends the hash map. </p>
  
  <p>I can't seem to get a hit on the case report I am testing. 
  I have even tried just making everything into an if-else-if structure, </p>
  
  <p>and that still didn't work out, 
  I've tried using a private enum method to no avail. </p>
  
  <p>I am at a loss here. 
  I am running Java 8. 
  I am open to any suggestion on optimizing the code as well. </p>
  
  <p>Thanks.</p>
  
  <pre><code>package linkedlist;
  
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.io.UnsupportedEncodingException;
  import java.util.LinkedHashMap;
  import java.util.Map;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  import javax.swing.JButton;
  import javax.swing.JFileChooser;
  import javax.swing.JLabel;
  
  /**
   *
   * @author admin
   */
  public class TextReaderGUI extends javax.swing.JFrame {
  
      JFileChooser fileChooser = new JFileChooser();
  
      String rawText;
  
      String[] text;
  
      public String listType;
  
      private JButton fileChooserButton;
      private JLabel statusLabel;
  
      /**
       * Creates new form TextReaderGUI
       */
      public TextReaderGUI() {
          initComponents();
      }
  
      /**
       * This method is called from within the constructor to initialize the form.
       * WARNING: Do NOT modify this code. The content of this method is always
       * regenerated by the Form Editor.
       */
      @SuppressWarnings("unchecked")
      // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;
      private void initComponents() {
  
          fileChooserButton = new javax.swing.JButton();
          statusLabel = new javax.swing.JLabel();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          fileChooserButton.setText("File Chooser");
          fileChooserButton.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  fileChooserButtonActionPerformed(evt);
              }
          });
  
          statusLabel.setText("Status: ");
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
                  .createSequentialGroup()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                          .addGroup(layout.createSequentialGroup().addGap(14, 14, 14).addComponent(fileChooserButton))
                          .addGroup(layout.createSequentialGroup().addGap(36, 36, 36).addComponent(statusLabel)))
                  .addContainerGap(264, Short.MAX_VALUE)));
          layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                  .addGroup(layout.createSequentialGroup().addGap(16, 16, 16).addComponent(fileChooserButton)
                          .addGap(18, 18, 18).addComponent(statusLabel).addContainerGap(221, Short.MAX_VALUE)));
  
          pack();
      }// &lt;/editor-fold&gt;
  
      private void fileChooserButtonActionPerformed(java.awt.event.ActionEvent evt) {
          // TODO add your handling code here:
          try {
              int returnVal = fileChooser.showOpenDialog(this);
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fileChooser.getSelectedFile();
  
                  rawText = "";
                  BufferedReader reader = new BufferedReader(new FileReader(file));
                  StringBuilder stringb = new StringBuilder();
                  String s;
                  while ((s = reader.readLine()) != null) {
                      stringb.append(s);
                      stringb.append("\n"); // this makes sure that java sees when a new line has started
                  }
                  rawText = stringb.toString();
                  statusLabel.setText("Status: " + file.getName());
              }
          } catch (IOException e) {
              statusLabel.setText("Status" + e);
          }
  
          text = rawText.split("\n"); // creating a string array split at each line break
  
          Map&lt;String, String&gt; lines = new LinkedHashMap&lt;&gt;();
  
          for (int i = 0; i &lt; text.length; i++) { // this sets the first word of the line = key
              String[] currentLine = text[i].split("\\s+"); // splits the words in the current line to an array
              if (i == 0) {
  
                  listType = currentLine[0].replaceAll("\n", "").replaceAll("\\s+", ""); // determines listType to pass
  
              }
              if (currentLine.length &gt; 1 &amp;&amp; i &gt; 0) {
                  lines.put(currentLine[0] + " " + i, currentLine[1]); // if two words exist on a line
                                                                          // the first is the key second is the value
              } else if (currentLine.length == 1 &amp;&amp; i &gt; 0) { // keeps list type out of key values
                  lines.put(currentLine[0] + " " + i, ""); // " " + i is used to ensure that each command is unique key
              }
          }
          lines.keySet().forEach((name) -&gt; {// Testing to see if document was correctly placed into the HashMap
              String key = name;
              String value = lines.get(name);
              System.out.println(key + " " + value + "\n");
          });
  
          System.out.println(listType); // testing to see if list type was correctly stored
  
          switch (listType) {
          case "stack":
              Stack stack = new Stack((LinkedHashMap) lines);
              break;
          case "queue":
              Queue queue = new Queue((LinkedHashMap) lines);
              break;
          case "dll":
              Dll dll = new Dll((LinkedHashMap) lines);
              break;
          case "sll":
              System.out.println("almost there");
              Sll sll = new Sll((LinkedHashMap) lines);
              break;
          case "cll":
              Cll cll = new Cll((LinkedHashMap) lines);
              break;
          default:
              System.out.println("something went wrong here");
              break;
          }
      }
  }
  </code></pre>