REGISTER FREE to Receive Instant Job

Friday, 7 November 2014

StringBuffer in Java

StringBuffer

  • Objects of StringBuffer represents mutable strings. Each StringBuffer object creates an array of default or specified capacity that is used to hold the contents of StringBuffer.
  • Default capacity of StringBuffer object is 16 characters.

StringBuffer objects can be created using following constructors:-

public StringBuffer();
public StringBuffer(int capacity);
public StringBuffer(String s);

Example:


Commonly  used  methods-

append ( ) method is used to append a primitive value or contents of a string to the StringBuffer.

public StringBuffer append(int i);
public StringBuffer append(char c);
public StringBuffer append(String s);
Example:

insert( ) method is used to insert a string at the given position in the StringBuffer object.

public StringBuffer insert(int index, String s);
Example:

replace( ) method is used to replace part of a StringBuffer object with the given string.

public StringBuffer replace(int startIndex, int endIndex, String s);

reverse ( ) method reverses the contents of StringBuffer.

public StringBuffer reverse();

toString( ) method returns the content of StringBuffer as an immutable string.

public StringBuffer toString();


2 comments:

  1. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Are you looking for the best Java training institute in Chennai?
    Come and learn with Aorta, the best java training institute in Chennai offering the best platform to learn and get the depth of Java
    java training in chennai
    java course in chennai

    ReplyDelete

Popular Posts

Powered by Blogger.

About Me

My photo

JobsAcid is a 'job search engine' to provide finding a job on the internet easier for the user. It has designed as huge selection of job offerings on the same search engine.