title: How to check if three user-input words in a string are identical?
body: <p>The following code alphabetizes three words in a user input string.</p>
  
  <p>Example: </p>
  
  <blockquote>
    <p>cat ant dog</p>
  </blockquote>
  
  <p>Output:</p>
  
  <blockquote>
    <p>ant cat dog</p>
  </blockquote>
  
  <p>What I'm trying to do, is make it so that if the three words are completely identical, it'll print out "these words are the exact same" or something on the lines of that.</p>
  
  <p>I'm not quite sure how to go about doing that. Any help or advice would be appreciated, thank you!</p>
  
  <pre><code>    final Scanner keyboard = new Scanner(System.in);
      System.out.print("Please enter three words : ");
      final String words = keyboard.nextLine();
      final String[] parts = words.split(" ");
      System.out.print("In alphabetical order those are: ");
           alphabetizing (parts);
           for ( int k = 0;  k &lt; 3;  k++ )
              System.out.print( parts [k] + " " );
  
  
  
    public static void alphabetizing( String  x [] )
    {
          int word;
          boolean check = true;
          String temp;
  
          while ( check )
          {
                check = false;
                for ( word = 0;  word &lt; x.length - 1;  word++ )
  
                {
                        if ( x [ word ].compareToIgnoreCase( x [ word+1 ] ) &gt; 0 )
                        {
                                    temp = x [ word ];
                                    x [ word ] = x [ word+1];
                                    x [ word+1] = temp;
                                    check = true;
  
                        }
                }
          }
    }
  </code></pre>