Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

Thanks&Cheers
venkat
 
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
Joe,
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

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!