Thursday, June 08, 2006

String And StringBuffer

..String and StringBuffer in Java..
String is represented as character array in C. Java takes up the similar concept, it represent String internally as Character Array with two pointers One is the offset from starting and the other one is length of the String which is used to protect the JVM from accessing memory area which is not yet allocated to the String. (C don't provide such a check). One of the most amazing thing is the fast access of substring function. Actually the substring function maintain only the new offset i.e. copy of the integers and directly access the main string from that pointer which results in faster accessing and instant make of the new String! But it has a large disadvantage... So Some people r using JINI to overcome that problem. Any guesses?
Check out the intersting article with all the answers.
http://fishbowl.pastiche.org/2005/04/27/the_string_memory_gotcha

String Buffer: String Buffer is same as String but it provide flexibility to the user, one of the main drawback of String is due to its constant nature that is Once it is written U can't put out or change the internals. For this the best Thing is to use StringBuffer which provide powerful function to append and update the existing. This will simply many tasks like removing/inserting a set of characters modifing and replacing current set etc. So StringBuffer is more powerful and internally represent the same architecture.
SCHEDULE:
"GARBAGE COLLECTOR will be posted after 6 Hrs"
"TUTORIAL UPDATION will be posted after 8 Hrs"
"Ebook collection listing will be posted after 10 Hrs"
"BEST PRACTICES will be posted after 14 Hrs"
Please leave your comment to let me know your topic of Interest.