Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending to a String 1

Status
Not open for further replies.

Enea

Technical User
Feb 23, 2005
90
US
I have the following:
StringBuffer s=new StringBuffer();
s.append("add this");

If I want to attach "ing" to the word add, meaning I want to have s="adding this" how do I append in between characters?

 
Use the insert(int offset, String str) method of StringBuffer.

Are you using the Java API Docs? If you are serious about using Java, then you CANNOT make progress without them. They would have alerted you to the presence of this method, for instance.

Tim
 
I am studying Java and using Eclipse.
When I enter the object name followed by a dot, I can see all the methods available to me. Is that what you meant?

Thank you for your reply. I tried it and it works.
 
Thanks Tim. I am not relying on code completion to learn the language; I have a couple of good books.
But thank you for the link you sent me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top