Java StringBuffer chartAt Example

StringBuffer class charAt method example. This example shows you how to use charAt method.


StringBuffer class charAt method example. This example shows you how to use charAt method.
public char charAt(int index)
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.
The index argument must be greater than or equal to 0, and less than the length of this sequence.

Here is the full code:
/**
* @(#) CharAtString.java        
 * A class representing charAt method
 @version  01-may-2008
 @author   RoseIndia
**/


public class CharAtString {
  public static void main(String args[]) {
    
    StringBuffer sb = new StringBuffer("Rose India");

    //Display the character at index 0:
    System.out.println("specified character is : " + sb.charAt(0));

    //Display the character at index 5:
    System.out.println("specified character is : " + sb.charAt(5));
  }
}

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US