• Post Reply Bookmark Topic Watch Topic
  • New Topic

StringBuffer  RSS feed

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public synchronized StringBuffer insert(int offset, String s)

Hi all
Can anybody provide a program with the implementation of the above method

Thanks&Cheers
venkat
 
Joe Sondow
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read the implementation code. It came with your JDK. Open your JDK folder and find the src.zip file. Unzip that file to a directory, and you can browse all of Sun's implementation code for the built-in classes, with the exception of native methods.

Here's the code for that method from the StringBuffer.java source file:
 
Saranyan Narayanan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
Venkat is probably asking , can a sample program show me how to use String buffer method insert()
 
Raghu Shree
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just give the simple example of how to use the StringBuffer method insert(). Some of the different version of insert method is given below.
public java.lang.StringBuffer insert(int, boolean);
public synchronized java.lang.StringBuffer insert(int, char);
public java.lang.StringBuffer insert(int, int);
public java.lang.StringBuffer insert(int, long);
public java.lang.StringBuffer insert(int, float);
public java.lang.StringBuffer insert(int, double);
public java.lang.StringBuffer insert(int offset, char[] str);


Here argument no 1 means place of the position to be inserted.
argument no 2 means which type of representation to be inserteed.


Output of the above program is
Javatrue Programming
Java-true Programming
Java1-true Programming
Java1111-true Programming
Java1.01111-true Programming
Java1.01.01111-true Programming
Java Good1.01.01111-true Programming
JavaHello Good1.01.01111-true Programming
JavaHaiHello Good1.01.01111-true Programming
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!