Skip to content

Blank page of code

Yet another developer blog …

How to clear a StringBuilder

There are three possible ways, but apparently the best one is to call setLength(0) on the StringBuilder object.

StringBuilder strBuilder = new StringBuilder();

// code that appends to strBuilder

strBuilder.setLength(0);

References

  • JavaCodeExamples – Java StringBuilder clear example, how to empty StringBuilder (StringBuffer)
Author GSzundyPosted on 2 de December de 2020Tags Java, StringBuilder

Post navigation

Previous Previous post: How to start VisualVM with custom JDK
Next Next post: How to add H2 database to a Spring Boot project

Search

Recent posts

  • How to add H2 database to a Spring Boot project 5 de December de 2020
  • How to clear a StringBuilder 2 de December de 2020
  • How to start VisualVM with custom JDK 2 de December de 2020
Blank page of code Proudly powered by WordPress