The StringBuilder Class

KH·2023년 5월 15일
0

JavaTutorial

목록 보기
11/11
post-thumbnail

StringBuilder objects are like String objects, except that they can be modified. Internally, these objects are treated like variable-length arrays that contain a sequence of characters. At any point, the length and content of the sequence can be changed through method invocations.

Strings should always be used unless string builders offer an advantage in terms of simpler code (see the sample program at the end of this section) or better performance. For example, if you need to concatenate a large number of strings, appending to a StringBuilder object is more efficient.

class Solution {
    public String solution(String my_string) {
        String ans = new StringBuilder(my_string).reverse().toString();
        return ans;
    }
}

doc: https://docs.oracle.com/javase/tutorial/java/data/buffers.html
code: https://school.programmers.co.kr/learn/courses/30/lessons/120822?language=java

profile
What, How, Why

0개의 댓글