This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
who do you think wrote the javadocs but programmers? The class was probably created because of feedback from programmers.
One of our goals here is to teach people to be better programmers, and not just hand them the answers. One of the ways to become a better programmer is to learn to read the documentation. If, after reading it, you have specific questions by all means post them. But simply saying "i don't want to read the docs, just tell me the answer" (which is how your post reads to me) is really not going to get you much around here.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Oct 06, 2008
Great thoughts Fred & I respect your opinions Regards
Joined: Oct 06, 2008
with due respect to Fred, going through the javadocs for stringbuilder presented in : StringBuilder javadocs
The following aspects are noted:
1) We can use StringBuffer or StringBuilder as long as these instances are used by only one thread. But in this case it is better to use StringBuilder as it is quick to implement & also it has overloaded append & insert methods.
2) But when we want to synchronize access to instance, then we can use StringBuffer as it is implicitly synchronized i.e out of multiple threads trying to access that instance , only one thread will be able to access that instance.
long story short, stringbuffer is a synchronized class implementation and stringbuilder is not both of them behave same but StringBuffer provide thread safety, but just for it's methods, which result in a small performance hit , which doesn't matter for small App but is fairly considerable where lots of objects are involved so it's better to use stringbuilder because it is fast, if you are dying for the thread safety feature(as -if you're using threads ) then stringbuffer provides some additional thread safety,
I am sorry; I didn't check who was posting, and I thought you were giving answers when you ought not to. So I deleted the answers, then realised that you had done what Fred suggested. Well done finding the details.
I am very sorry about that mistake.
I have, fortunately, been able to restore the original text of your posts, plus an "edited by Campbell Ritchie."
By the way: it is probably acceptable to say "with due respect" in India, or the USA, but in England it is considered very rude.