charAt( ) method when used with StringBuffer extracts the character from the specified string using the provided index.
Example:
StringBuffer object1 = new StringBuffer("abcdef");
object1.charAt(3); -> Will extract the character at index 3 in the specified string "abcdef" i.e. 'd'
Lets implement this on Eclipse IDE:
1. Create 'charAtDemo' class under any project as shown below:
3. Observe that the output is displayed in the console as shown below:
Click here to download this project containing the class file used in this post (You can download this project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
Using 'setCharAt( )' method with StringBuffer will be explained in the next post.
No comments:
Post a Comment