Saturday, May 30, 2009

Java Basics Using Qt Jambi Tutorial

String Builder Class

You can use this class to append or insert strings (just like concatenating strings, "String.concat()").


Ex.

String s =”hello”; //declare assign string “hello” to s.

StringBuilder sb=new StringBuilder(s); //creates an instance of class StringBuilder and puts the string s to sb StringBuilder.

sb.insert(4,”o”); //would insert the “n” inside the string “hello” and will be “helloo”.

sb.append(“world”); //will make “hello” string to “helloworld”.

Note: Append will always put the string at the end of the original string.

to be continued...

No comments: