Answers for "string builder in jav"

10

java string builder

StringBuilder stringBuilder = new StringBuilder();

stringBuilder.append("string");

System.out.println("String = " + stringBuilder.toString());
Posted by: Guest on September-06-2020
1

string builder in java

Java StringBuilder class is used to create
  mutable (modifiable) string. The Java
  StringBuilder class is same as StringBuffer
  class except that it is non-synchronized.
    
StringBuilder()
    creates an empty string Builder with the initial capacity of 16.
StringBuilder(String str)
    creates a string Builder with the specified string.
StringBuilder(int length)
    creates an empty string Builder with the specified capacity as length.  

StringBuilder builder = new StringBuilder("Harvard"); 
// mutable you modify object new keyword ile olusturuoyrsun StringBuilder
        builder.append(" School"); 
// append method we are calling from Builder 
//** it is not synchronized means fast
        System.out.println(builder); // Harvard School
Posted by: Guest on June-09-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language