Candibiotic
News Update :

Using String, StringBuffer, and StringBuilder

Friday, August 21, 2009

String objects are immutable, and String reference variables are not.
If you create a new String without assigning it, it will be lost to your program.
If you redirect a String reference to a new String, the old String can be lost.
String methods use zero-based indexes, except for the second argument of substring().
The String class is final—its methods can't be overridden.
When the JVM finds a String literal, it is added to the String literal pool.
Strings have a method: length(), arrays have an attribute named length.
The StringBuffer's API is the same as the new StringBuilder's API, except that StringBuilder's methods are not synchronized for thread safety.
StringBuilder methods should run faster than StringBuffer methods.
All of the following bullets apply to both StringBuffer and StringBuilder:
* They are mutable—they can change without creating a new object.
* StringBuffer methods act on the invoking object, and objects can change without an explicit assignment in the statement.
* StringBuffer equals() is not overridden; it doesn't compare values.
* Remember that chained methods are evaluated from left to right.
* String methods to remember: charAt(), concat(), equalsIgnoreCase(), length(), replace(), substring(), toLowerCase(), toString(), toUpperCase(), and trim().
* Stringbuffer methods to remember: append(), delete(), insert(), reverse(), and toString()
Share this Article on :

0 comments:

Post a Comment

 

© Copyright Vinayak Wins 2010 -2011 | Design by Herdiansyah Hamzah | Published by Borneo Templates | Powered by Blogger.com.