The method you're looking for is charAt. Here's an example:

String text = "foo";
char charAtZero = text.charAt(0);
System.out.println(charAtZero); // Prints f

For more information, see the Java documentation on String.charAt. If you want another simple tutorial, this one or this one.

If you don't want the result as a char data type, but rather as a string, you would use the Character.toString method:

String text = "foo";
String letter = Character.toString(text.charAt(0));
System.out.println(letter); // Prints f

If you want more information on the Character class and the toString method, I pulled my info from the documentation on Character.toString.

Answer from Ricardo Altamirano on Stack Overflow
🌐
W3Schools
w3schools.com › java › ref_string_charat.asp
Java String charAt() Method
Java Examples Java Videos Java ... Java Syllabus Java Study Plan Java Interview Q&A ... The charAt() method returns the character at the specified index in a string....
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-get-a-character-from-a-string
Java Program to Get a Character from a String - GeeksforGeeks
August 26, 2026 - public class GFG { public static ... System.out.println("Character at index " + index + " is: " + ch); } } ... The chars() method creates an IntStream of the string's UTF-16 code units....
🌐
Baeldung
baeldung.com › home › java › java string › getting a character by index from a string in java
Getting a Character by Index From a String in Java | Baeldung
November 24, 2025 - Let’s take a look at the method signature from the String class: ... The charAt() method returns the char at the index specified in the input parameter.
🌐
IIT Kanpur
iitk.ac.in › esc101 › 05Aug › tutorial › java › data › getchar.html
Getting Characters by Index from a String or String Buffer
You can get the character at a particular index within a string, string buffer, or string builder by invoking the charAt accessor method. The index of the first character is 0; the index of the last is length()-1.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › data › manipstrings.html
Manipulating Characters in a String (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)
The String class has a number of methods for examining the contents of strings, finding characters or substrings within a string, changing case, and other tasks. You can get the character at a particular index within a string by invoking the charAt() accessor method.
🌐
Vultr Docs
docs.vultr.com › java › standard library › java › lang › string › charat()
Java String charAt() - Get Character At Index | Vultr Docs
November 19, 2024 - compareTo()charAt()compareToIgnoreCase()concat()contains()valueOf()length()matches()isEmpty()endsWith()split()indexOf()equalsIgnoreCase()hashCode()intern()Show more (16) ... The charAt() method in Java is a straightforward yet essential function ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-charat-method-example
Java String charAt() Method - GeeksforGeeks
June 1, 2026 - If the index value is greater than ... s = "Java String charAt() example"; // Retrieve and print the character at index 8 char ch = s.charAt(8); System.out.println(ch); // Retrieve and print the character at index 24 ch = s.charAt(24); ...
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › java › java string indexing
How to Get Character in String by Index in Java | Delft Stack
February 2, 2024 - Java provides a convenient toCharArray() method that returns a char array. We can use this method on a string and get a char array for it. public class Demo { public static void main(String[] args) { String s = "test string"; char[] charArr ...
🌐
W3Docs
w3docs.com › java
Get string character by index
In Java, you can get a character at a specific index in a string using the charAt() method of the String class.
🌐
w3resource
w3resource.com › java-exercises › string › java-string-exercise-1.php
Java - Get the character at the given index within the String
May 21, 2025 - System.out.println("The character at position 0 is " + (char)index1); // Print the character at position 0 by converting ASCII value to char. System.out.println("The character at position 10 is " + (char)index2); // Print the character at position ...
🌐
Tutorialspoint
tutorialspoint.com › java › lang › string_charat.htm
Java - String charAt() Method
The Java String charAt() method is used to retrieve the character at the specified index. The indexes refer to the character position in the sequence. The first char value represents the 0th index, and the next char value represents the 1st ...
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-string-charat-method-example
Java String charAt() Method example
September 11, 2022 - The Java String charAt(int index) method returns the character at the specified index in a string. The index value that we pass in this method should be between 0 and (length of string-1). For example: s.charAt(0) would return the first character of the string represented by instance s.
🌐
IncludeHelp
includehelp.com › java › string-charat-function-to-get-character-by-index-from-string.aspx
Java - Getting a character by index from a string
January 29, 2024 - So, be careful while using index in the string. In this example, there is string initialized by "Hello world!" and we have to access its 0th and 7th character. public class Main { public static void main(String[] args) throws java.lang.Exception { String msg = "Hello world!"; System.out.println("Character at 0th index: " + msg.charAt(0)); System.out.println("Character at 7th index: " + msg.charAt(7)); } }
🌐
Scientech Easy
scientecheasy.com › home › blog › how to get character from string in java
How to Get Character from String in Java - Scientech Easy
June 2, 2025 - This charAt() method of string class returns the character located at the specified index within a string. It accepts an integer value that represents an index number.
🌐
Career Karma
careerkarma.com › blog › java › a step-by-step guide to charat in java
A Step-By-Step Guide to charAt in Java | Career Karma
December 1, 2023 - The Java charAt() method retrieves the character that exists at a particular index value within a string.
🌐
CodeGym
codegym.cc › java blog › strings in java › java string charat()
Java String charAt()
February 20, 2025 - The Java string class charAt() method returns the character at the specified index of a string. This specified index is provided as a parameter and it ranges from 0 to n-1, where n represents the length of the string.
🌐
DEV Community
dev.to › satyam_gupta_0d1ff2152dcc › master-the-java-charat-method-your-ultimate-guide-with-examples-use-cases-3742
Master the Java charAt() Method: Your Ultimate Guide with Examples & Use Cases - DEV Community
November 1, 2025 - So, grab your favorite beverage, and let's get into it. What is the Java String charAt() Method? Let's Demystify It. In the simplest terms, charAt() is a built-in method of the Java String class.