fastread homefastrread library fastread menu

Java : String charAt

Tutorial by:      Date: 2016-04-30 01:05:01

❰ Previous Next ❱

The java string charAt() method returns a char value at the given index number. The index number starts from 0.


Signature

The signature of string charAt() method is given below:

 
  1. public char charAt(int index)  

Parameter

index : index number, starts with 0


Returns

char value


Specified by

CharSequence interface


Throws

IndexOutOfBoundsException : if index is negative value or greater than this string length.


Java String charAt() method example

 
  1. public class CharAtExample{  
  2. public static void main(String args[]){  
  3. String name="javatpoint";  
  4. char ch=name.charAt(4);//returns the char value at the 4th index  
  5. System.out.println(ch);  
  6. }}  

t

❰ Previous Next ❱


Java

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website