It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes append() and insert() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "append() and insert()" Watch "append() and insert()" New topic

append() and insert()

prashantK Singh

Joined: Sep 11, 2006
Posts: 19
hi all
kidly someone explain me that what is the difference between
append () and insert()
Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
append basically appends the text inside a append statement to the current text in a StringBuilder or StrinBuffer.
e.g:- StringBuilder test = new StringBuilder("abc");

and the result is abcdef

for insert basically it appends the string to the position specified inside the parenthesis.
e.g:- StringBuilder test = new StringBuilder("ac");

result is abc. it basically adds the character to the position specified as '1'. the int off set parameter in the insert() is zero based.

hope this helps.

Dinuka Arseculeratne

if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
prashantK Singh

Joined: Sep 11, 2006
Posts: 19
thank you dinuka
I agree. Here's the link:
subject: append() and insert()
It's not a secret anymore!