
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Character at Specified Index in String using Java
Use the charAt() method in Java to get a character located at a specified index.
Let’s say the following is our string.
String str = "Laptop...";
Finding character at 3rd position.
str.charAt(2);
The following is the final example.
Example
public class Demo { public static void main(String[] args) { String str = "Laptop..."; System.out.println("String: "+str); System.out.println("Character at position 3 = " +str.charAt(2)); } }
Output
String: Laptop... Character at position 3 = p
Advertisements