3:44 pm - Sunday June 25, 2017

To CharAt using StringBuffer CharAt Method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

In this Tutorial you will learn how to   CharAt  Using StringBuffer CharAt Method With Example program.

public class StringBufferCharAtExample {
	public static void main(String args[]) {
		StringBuffer sb = new StringBuffer("Students Name List:");
		System.out.println(sb.charAt(9));
	}
}

Output

N

Explanation:

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.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Specified by:

charAt in interface CharSequence

Parameters:

index – the index of the desired char value.

Returns:

the char value at the specified index.

Throws:

IndexOutOfBoundsException – if index is negative or greater than or equal to length().

See Also:

length()

BACK

Filed in: Java Examples

Comments are closed.