title: Java string not equals
body: <p>So I have String array</p>
  <pre><code>String[] faculties = new String[21];
  </code></pre>
  <p>and I need to fill it with the names of faculties from .txt file that looks like</p>
  <blockquote>
  <p>Math &amp; CS; First Speciality; First Program; etc</p>
  <p>Math &amp; CS; Second Speciality; First Program; etc</p>
  <p>Math &amp; CS; Second Speciality; Second Program; etc</p>
  <p>Physics; First Speciality; First Program; etc</p>
  <p>Physics; First Speciality; Second Program; etc</p>
  </blockquote>
  <p>I use the next code to get these names</p>
  <pre><code>FileReader input = new FileReader(&quot;faculties1.txt&quot;);
  BufferedReader bufRead = new BufferedReader(input);
  String myLine;
  int f = 0;
  
      while((myLine = bufRead.readLine())!= null){
          String[] arr = myLine.split(&quot;;&quot;);
  
          if(f == 0){
              faculties[f] = arr[0];
              f++;
          }
          else{
              if(!faculties[f-1].trim().equals(arr[0].trim())){
                  faculties[f] = arr[0];
                  f++;
              }
          }
      }
  </code></pre>
  <p>but when I try to check my array</p>
  <pre><code>for(int i = 0; i &lt; f; i++){
          System.out.println(faculties[i]);
      }
  </code></pre>
  <p>console says me</p>
  <blockquote>
  <p>﻿Math &amp; CS</p>
  <p>Math &amp; CS</p>
  <p>Physics</p>
  </blockquote>
  <p>I dont get why Java puts &quot;Math &amp; CS&quot; second time to my array.</p>