title: Two name combination using for loop in java
body: <p>What I want is that asks the user to enter three (3) first names then display the following:
  All the possible two-name combinations. <br> For example I will input Mike Tyler Bryle<br></p>
  <blockquote>
  <p>Mike Tyler <br> Mike Bryle <br> Tyler Mike <br> Tyler Bryle <br> Bryle Mike <br> Bryle Tyler</p>
  </blockquote>
  <p>Here is my code</p>
  <pre><code>import java.io.*;
  import java.util.*;
  
  public class Javacomprog{
    
      public static void main(String[] args) {
          
          //GET THE NAME FIRST
         String name_1, name_2, name_3;
         String prints =&quot; &quot;;
         //STORING THE 3 NAMES
         String[] a_names = new String[3];
         //COMBINATION NAME
         String[] c_names = new String[3];
         
         Scanner sc = new Scanner(System.in);
         
         //STORE IN ARRAY THE USER INPUT NAMES
         System.out.println(&quot;Enter three first names:&quot;);
         for(int i = 0; i &lt; a_names.length; i++){
             a_names[i] = sc.nextLine();
         }
         // STORE THE NAME COMBINATION
         for(int j = 0; j &lt; a_names.length; j++){
  
          int a = 0;
          
          //CHECK IF IT IS A REPEATED NAME USING EQUAL IGNORECASE
          if(a_names[a].equalsIgnoreCase(a_names[j]) == true){
           a++;
          }
           c_names[j] = a_names[a]+ &quot; &quot; + a_names[j];
     
      
         }
         //PRINT NAME COMBINATION
         for(int l = 0; l &lt; c_names.length; l++){
          System.out.println(c_names[l] + &quot; &quot;);  
         }
         
  
  
      }
      
  }
  </code></pre>
  <p>Can you explain how do I do the name combination using for loop thank you.</p>