• 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

String Builder Class

 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the meaning of synchronized methods and
what does this sentence actualy mean-"StringBuilder class consists of mutable sequence of charecters"
and what does 'thread-safe' mean
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at Synchronization in Sun's Java tutorials.

A piece of code is thread-safe if it still works correctly when multiple threads execute it at the same time. (Click on the link, the Wikipedia article explains it in much more detail).

About "StringBuilder class consists of mutable sequence of charecters": Class StringBuilder contains a sequence of characters, which you can modify - unlike for example class String, which is immutable.
 
Marshal
Posts: 79392
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you read the StringBuilder documentation, you find it has lots of methods called "delete" or "insert" or "append" with void return types. It allows you to alter the contents of "writing" and then turn it to a String with the toString() method.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:lots of methods called "delete" or "insert" or "append" with void return types.


Not void, StringBuilder. These methods return another reference to the StringBuilder object itself that allows you to chain methods. For example:
 
Campbell Ritchie
Marshal
Posts: 79392
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Rob, I had forgotten about the return types. Sorry.
 
reply
    Bookmark Topic Watch Topic
  • New Topic