title: Use of array list and String comparison
body: <p>I need to read the names from a array list and compare them using loops and print the values from the array in the list</p>
  
  <hr/>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  public class UniqueName {
  
      public static void main(String args[]) throws IOException{
          int wordcount = 0;
  
          Scanner input = new Scanner(new FileReader("Names.txt"));
  
          while (input.hasNextLine()) {
          String line = input.nextLine();
  
             String str [] = line.split((" "));
                for ( int i = 0; i &lt;str.length ; i ++) {
                  if (str [i].length() &gt; 0) {
                    wordcount ++; 
  
                  }
  
                  }
  
          }
          System.out.println(wordcount);
      }
  }
  </code></pre>