• Post Reply Bookmark Topic Watch Topic
  • New Topic

String Builder Class  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • 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
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Rob, I had forgotten about the return types. Sorry.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!