title: How to replace multiple words in a single string in Java?
body: <p>I'm writing a program that will replace multiple words in a single string.  I'm using this code but it is replacing word but giving result in two different lines.  I want multiple words replaced and output in one single line.</p>
  
  <pre><code>import java.util.*;
  public class ReplaceString {
      public static void main(String[] args) {
          new ReplaceString().run();
      }
  
      public void run()
      {
  
          System.out.println("Input String:\n");////
          Scanner keyboardScanner = new Scanner(System.in);/////
          String inString = keyboardScanner.nextLine();/////
          String strOutput = inString.replace("call me","cm");
          System.out.println(strOutput);
  
          String strOutput1 = inString.replace("as soon as possible","asap");
          System.out.println(strOutput1);      
  
      }
  }
  </code></pre>