Java StringBuffer CharAt
Chapter:
String Handling
Last Updated:
27-05-2017 14:57:11 UTC
Program:
/* ............... START ............... */
public class JavaStringBufferCharAt {
public static void main(String[] args) {
StringBuffer buff = new StringBuffer("JavaScan.com ");
System.out.println("buffer = " + buff);
// returns the char at index 4
System.out.println("character = " + buff.charAt(4));
}
}
/* ............... END ............... */
Output
buffer = JavaScan.com
character = S
Notes:
-
The java.lang.StringBuffer.charAt() method returns the char value in this sequence at the specified index. The first char value is at index 0, the next at index 1, and so on, as in array indexing.
Tags
StringBuffer CharAt, Java, String