Languages
[Edit]
EN

Java - Remove last 2 characters from string builder in java

10 points
Created by:
Payne
654

Remove last 2 characters from StringBuilder in Java

Syntax:

sb.delete(sb.length() - 2, sb.length());

Example:

StringBuilder sb = new StringBuilder();

sb.append("12345");
System.out.println(sb.toString()); // 12345

sb.delete(sb.length() - 2, sb.length());
System.out.println(sb.toString()); // 123

https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - StringBuilder class

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join