title: Formatting String Output in Java
body: <p>I am trying to format a string in the output differently than the way it is already formatted within my program. It's a pizza ingredient menu and in the bulk of the program whenever it's outputted it is formatted right with a "\n" between the ingredients so as to create a list "feel". However, in the final menu where the users choice is displayed, I want to also put the ingredient list because the user can customize which ingredients are on their pizza. This is difficult with a vertical list of the ingredients because it can make the final output really long if the user has more than one pizza. I'm trying to find out if there's a way I can take the same string that was formatted for vertical display and display it horizontally with a comma between the ingredients instead of "\n". Any ideas? Or should I just create a new string that's formatted the way I want with the information I need?</p>
  
  <pre><code>String i1 = "Pepperoni", i2 = "Sausage", i3 = "Canadian Bacon";
  String ingredients = i1 + "\n" + i2 + "\n" + i3 + "\n";
  System.out.print(ingredients);
  System.out.printf("Your pizza includes only these ingredients: %s", ingredients);
  </code></pre>
  
  <p>The first System.out.print(ingredients) is similar to the code that I have that prints the ingredients vertically throughout the program so that it's easily readable to the user.</p>
  
  <p>The second System.out.print(...) is what I'm trying to format so that the list of ingredients displays horizontally.</p>