• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

StringBuffer help

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I and in an intro to object-based programming class and and having a problem with using StringBuffer object. I need to append a the object but the substring need to be inserted in to the middle and I can't figure out what i am doing wrong. I just need an i dea of what parameters i need.

thanks 4 the help

tyler
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Have you looked at the API documentation for StringBuffer? What exactly have you tried?

(PS: Please don't use "4" in place of "for." Thanks!)
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method you need is insert(int offSet, Object obj).

Example:

StringBuffer sb = new StringBuffer("Helo World");
sb.insert(2, new StringBuffer("l")); //inserting as Object from type StringBuffer

Or

StringBuffer sb = new StringBuffer("Helo World");
sb.insert(2, "l"); //inserting as Object from type String (String is an object)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic