title: What are the differences between char literals '\n' and '\r' in Java?
body: <p>In Java, the newline and carriage return characters are both seem to be showing same effect.</p>
  
  <p>What are the actual differences between char literals <code>\n</code> and <code>\r</code> in Java?</p>
  
  <hr>
  
  <p>Note that the above asks about the <code>\n</code> <em>character</em>, not the <code>newLine()</code> function on <code>BufferedWriter</code>, and so <a href="https://stackoverflow.com/questions/3307747/difference-between-newline-and-carriage-return-r">this other question</a> isn't relevant.</p>