• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

StringBuffer  RSS feed

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

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:
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Venkat is probably asking , can a sample program show me how to use String buffer method insert()
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

He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
global solutions you can do in your home or backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!