Swapping words in Java
<p>I am a newcomer to Java and want to swap two words that are entered into the program and then saved as a string. I included an if statement to make sure the two words I want to switch are entered. </p>

<pre><code>  Scanner in = new Scanner(System.in);
  System.out.println("Please enter at least one thing you love and one thing you hate using the words hate and love: ");
  String loveHate = in.nextLine();



  if (loveHate.indexOf( "love" ) == -1 || loveHate.indexOf( "hate" ) == -1 ){
    System.out.println("Please include the words love and hate.");
    return; 
  }
</code></pre>

<p>I want to take the sentence the user inputs and switch the words love and hate and then reprint a new string with the words switched. </p>
