Sep 17, 2018

Clear or empty a StringBuilder in Java

Two ways:

  1. Use stringBuilderObj.setLength(0).
  2. Allocate a new one with new StringBuilder() instead of clearing the buffer