티스토리 뷰
StringBuffer
StringBuffer class is rewritable, unlike String class which is not allowed to change itself once it is declared. String is immutable.
Methods of StringBuffer class
1. append
1 2 3 | StringBuffer sb = new StringBuffer("Hello "); sb.append("StringBuffer"); // add new string System.out.println(sb);//prints Hello StringBuffer | cs |
2. insert
1 2 3 | StringBuffer sb = new StringBuffer("Hello "); sb.insert(3,"StringBuffer"); System.out.println(sb);//prints HelStringBufferlo | cs |
3. replace
1 2 3 | StringBuffer sb = new StringBuffer("Hello"); sb.replace(0,2,"StringBuffer"); System.out.println(sb);//prints StringBufferlo | cs |
4. delete
1 2 3 | StringBuffer sb = new StringBuffer("Hello"); sb.delete(0,1); System.out.println(sb);//prints llo | cs |
Reference
https://www.javatpoint.com/StringBuffer-class
'JAVA' 카테고리의 다른 글
Exception handling in Java (0) | 2019.06.24 |
---|---|
Object type casting(upcasting,downcasting) example in Java (0) | 2019.06.17 |
Difference between Collection and Collections in Java (0) | 2019.02.26 |
How to convert Arrays to List (0) | 2019.02.26 |
Lambda Expression in Java (0) | 2019.02.22 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- repeat()
- hackerrank javascript
- Object type casting
- ... in Javascript
- easy javascript algorithm
- 알고리즘
- 프로그래머스 알고리즘
- 프로그래머스
- javascript
- easy algorithm
- spring boot application
- algorithm
- math.max
- string class in java
- 프로그래머스 알고리즘문제
- java
- compareTo()
- substring()
- equals()
- rest parameter
- hackerrank solution
- hackerrank javascript solution
- hackerrank
- Collection Framework
- C++
- Javascript Algorithm
- HashMap
- code refactoring
- math.abs
- HackerRank Algorithm
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함