Table of Contents
String’s charAt method returns char value present at specified index. String is nothing but Sequence of char values and it starts with index 0.
When you run above program, you will get below output:
Method Signature:
1 2 3 |
public char charAt(int index) |
String charAt Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package org.arpit.java2blog; public class StringCharAtMain { /* * @Author : Arpit Mandliya */ public static void main(String args[]) { String str="java2blog"; System.out.println("char at index 5 :"+str.charAt(5)); System.out.println("char at index 7 :"+str.charAt(7)); } } |
1 2 3 4 |
char at index 5 :b char at index 7 :o |
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.