Google+

146. Using 'charAt( )' method with StringBuffer







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:



2. Save and Run the 'charAtDemo' class file
3. Observe that the output is displayed in the console as shown below:



Download this project:

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:

Blog Index