aspose file tools
The moose likes Beginning Java and the fly likes String Builder Class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "String Builder Class" Watch "String Builder Class" New topic
Author

String Builder Class

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 984

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


http://www.lifesbizzare.blogspot.com || OCJP:81%
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12950
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
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

Joined: Oct 27, 2005
Posts: 19232

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:


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Yes, Rob, I had forgotten about the return types. Sorry.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String Builder Class
 
Similar Threads
anonymous class
public static final variable
convenience class
Thread Safe
Cohesion in Class Diagram