Stringbuffer And Stringtokenizer
String Buffer:
The StringBuffer class in Java is the same as String class except it is mutable i.e. it can be changed.
What is a mutable String?
String that can be modified or changed is known as mutable String. StringBuffer and StringBuilder classes are used for creating mutable strings.
Important methods of StringBuffer class
- StringBuffer Class append() Method
- StringBuffer insert() Method
- StringBuffer replace() Method
- StringBuffer delete() Method
1) StringBuffer Class append() Method
The append() method concatenates the given argument with this String.
Example:
2) StringBuffer insert() Method
The insert() method inserts the given String with this string at the given position.
Example:
3) StringBuffer replace() Method
The replace() method replaces the given String from the specified beginIndex and endIndex.
Example:
4) StringBuffer deleteCharAt() Method
The deleteCharAt () method of the StringBuffer class deletes the Character from the String.
Example:
- It is simple way to break a String. It is a legacy class of Java.
- The java.util.StringTokenizer class allows you to break a String into tokens.
Here, In this example we can count how many tokens are available in the String.The default delimiter is Space.
Here,In this example we can display the how many tokens are available in this String.
Comments
Post a Comment