aspose file tools*
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
Author

append() and insert()

prashantK Singh
Greenhorn

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");
test.append("def");
System.out.println(test);

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");
test.insert(1,"b");

System.out.println(test);
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
Greenhorn

Joined: Sep 11, 2006
Posts: 19
thank you dinuka
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: append() and insert()
 
Similar Threads
why am I getting a null pointer exception when I run this?
inserting 2.5 million records.....
Game on SQL
padding strings - left and right
Problems with java and mysql error: 1064