- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to access character of a string
To access character of a string in Java, use the charAt() method. The position is to be added as the parameter.
Let’s say we have the following string −
String str = "laptop";
Let’s find the character at the 4th position using charAt() method.
str.charAt(3));
The following is the final example.
Example
public class Demo { public static void main(String[] args) { String str = "laptop"; System.out.println("String: "+str); // finding character at 4th position System.out.println("Character at 4th position: "+str.charAt(3)); } }
Output
String: laptop Character at 4th position: t
- Related Articles
- Java Program to locate a character in a string
- Java program to convert a character array to string
- Java Program to Convert Character to String
- Java Program to Find the Frequency of Character in a String
- Java Program to Get a Character From the Given String
- Java program to check occurence of each character in String
- Java program to check occurrence of each character in String
- Java Program to Iterate through each character of the string.
- Java program to find the Frequency of a character in a given String
- Java Program to replace all occurrences of a given character in a string
- Java Program to Replace the Spaces of a String with a Specific Character
- Java Program to Capitalize the first character of each word in a String
- Java program to check if a string contains any special character
- Java Program to create Character Array from String Objects
- JAVA Menu Driven Program to Check Character is String, Number or Special Character

Advertisements