append() method in JAVA

1. The StringBuffer class in Java is a dynamic string array.
2. The StringBuffer class contains the append() method. The append() method is equivalent to “+”, which appends the specified string to this character sequence.
3. The string appended by StringBuffer.append() is at the same memory address.

public class Test{
  public static void main(String args[]){
    StringBuffer sBuffer = new StringBuffer("aaa");
    sBuffer.append("bbb");
    sBuffer.append("ccc");
    sBuffer.append("ddd");
    System.out.println(sBuffer);  
  }
}
Running result: aaabbbcccddd

Related Posts

A simple tutorial on how to use the MybatisX plug-in in SpringBoot (super detailed!!)

Windows 11 configure JDK environment variables

[ElasticSearch Series 6] Use QueryBuilders and NativeSearchQuery to implement various operations of es database on lists {multiple conditions, paging, sorting, highlighting (with highlighting tool class), etc.}

Multi-threaded learning

Forest detailed introduction

Java login Kerberos authentication expiration problem

[Alibaba Cloud] SMS service

The value taken out from Redis by redisTemplate.opsForValue().get(KEY) is null and the stored key is quoted.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*