title: Return or Print StringBuilder? Java
body: <p>I am a bit confused about the StringBuilder. It seems that when I print a StringBuilder, there it no need to add .toString() because it will automatically give me a string representation. However, when I return a StringBuilder object, I have to add the .toString(). Is that true? and why?</p>
  
  <p>Also, I am bit confused about the following code: </p>
  
  <pre><code>package com.tutorialspoint;
  import java.lang.*;
  public class StringBuilderDemo {
      public static void main(String[] args) {
  
          StringBuilder str = new StringBuilder("India ");
          System.out.println("string = " + str);
  
          // append character to the StringBuilder
          str.append('!');
          // convert to string object and print it
          System.out.println("After append = " + str.toString());
  
          str = new StringBuilder("Hi "); 
          System.out.println("string = " + str);
          // append integer to the StringBuilder
          str.append(123);
          // convert to string object and print it
          System.out.println("After append = " + str.toString());
      }
  }
  </code></pre>
  
  <p>For the different println, sometimes this code use toString and some other times it didn't. Why? I tried deleting the toString and the results are the same. Is it still necessary to use toString in println?</p>
  
  <p>Thanks so much for helping a newbie out!</p>