
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Append Method in Java
The append(char c) method of the java.lang.StringBuffer appends the string representation of the char argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by 1.
Example
import java.lang.*; public class StringBufferDemo { public static void main(String[] args) { StringBuffer buff = new StringBuffer("tuts "); System.out.println("buffer = " + buff); // appends the char argument as string to the string buffer. buff.append('A'); // print the string buffer after appending System.out.println("After append = " + buff); buff = new StringBuffer("abcd "); System.out.println("buffer = " + buff); // appends the char argument as string to the string buffer. buff.append('!'); // print the string buffer after appending System.out.println("After append = " + buff); } }
Output
buffer = tuts After append = tuts A buffer = abcd After append = abcd !
Advertisements