title: How to get the Scanner to scan all the elements in an array, in java
body: <p>This is the Question:  Create an array of Strings and assign 5 names to it. Ask the user what their name is, if their name is the same as one that is already in the list do something. Get creative!, use a for-each loop to print every name in the array with a space in-between each indices.</p>
  <p>This is what I have so far. One of the issues I am having is that the scanner is only comparing the input to the first name on the array and not the rest.</p>
  <pre><code>public static void main(String[] args) {
      
  
      String[] names = {&quot;Jose&quot;, &quot;Alex&quot;, &quot;Steven&quot;, &quot;Sky&quot;, &quot;Ana&quot;};
  
      Scanner scan = new Scanner(System.in);
      System.out.println(&quot;What is your name? &quot;);
      
      String input = scan.next();
      
      for (String n:names) {
          if (n.equalsIgnoreCase(input)) {
              System.out.print(&quot;Hooray! Your odds of finding a keychain with your name on it are high! =) &quot;);
          }
          
          
          else { 
              System.out.print(&quot;Welcome to the rare names club!!! =D &quot; );
              System.out.print(names + &quot; &quot;);
              
              }
          break;
      
          }
      }
  }
              
      
  </code></pre>
  <p>Feel free to comment on any other issues you see. I am new at this and I'd appreciate an feedback. Thx</p>