Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

Java – String Class Methods

1) charAt()

2) getChars()

3) getBytes()

4) toCharArray()

5) equals()

6) equalsIgnoreCase()

7) regionMatches()

8) startsWith()

9) endsWith()

10) compareTo()

11) contains()

12) copyValueOf()

13) IndexOf()

14) lastIndexOf()

15) subString()

16) concat()

17) replace()

18) trim()

19) toLowerCase()

20) toUpperCase()

21) join()

22) split()

23) length()


Java – charAt()

This method returns the character value present at the specified index.

Syntax

char charAt(int index)

Example

 public class CharAtDemo 
 {
     public static void main(String args[])
     {
         String name = "James Smith";
         char ch1 = name.charAt(3);
         char ch2 = name.charAt(6);
         char ch3 = name.charAt(9);
		
         System.out.println("character At index 3 :: "+ch1);
         System.out.println("character At index 6 :: "+ch2);
         System.out.println("character At index 9 :: "+ch3);
     }
 }

Output

character At index 3 :: e
character At index 6 :: S
character At index 9 :: t

Java Programming Language String Class Method 1

Leave a reply