Use this:
String str = "testString";
char[] charArray = str.toCharArray();
Character[] charObjectArray = ArrayUtils.toObject(charArray);
Answer from Kuldeep Jain on Stack OverflowW3Schools
w3schools.com › java › ref_string_tochararray.asp
Java String toCharArray() Method
Java Examples Java Videos Java ... Syllabus Java Study Plan Java Interview Q&A ... The toCharArray() method returns a new char array representing the contents of the string....
GeeksforGeeks
geeksforgeeks.org › java › convert-a-string-to-character-array-in-java
Convert a String to Character Array in Java - GeeksforGeeks
Note: We can use the charAt() method, that returns the character at the specified index of a string., where the index is zero-based. Java Streams provide a functional way to convert a string into characters and process them for modern Java applications.
Published: July 12, 2025
How to Convert Char Array to String in Java | FULL GUIDE
02:38
Java Program to Convert Character Array to String - YouTube
02:43
Java Program to Convert char array to String with Explanation - ...
How To Convert Char Array To String In Java
01:44
How to Convert String to Char Array in Java | FULL GUIDE - YouTube
How To CONVERT Char Array To String In Java (QUICK ...
Top answer 1 of 14
227
Use this:
String str = "testString";
char[] charArray = str.toCharArray();
Character[] charObjectArray = ArrayUtils.toObject(charArray);
2 of 14
94
One liner with java-8:
String str = "testString";
//[t, e, s, t, S, t, r, i, n, g]
Character[] charObjectArray =
str.chars().mapToObj(c -> (char)c).toArray(Character[]::new);
What it does is:
- get an
IntStreamof the characters (you may want to also look atcodePoints()) - map each 'character' value to
Character(you need to cast to actually say that its really achar, and then Java will box it automatically toCharacter) - get the resulting array by calling
toArray()
Tutorialspoint
tutorialspoint.com › java › lang › string_tochararray.htm
Java - String toCharArray() Method
The Java String toCharArray() method is used to convert the current string to a character array. This method returns a newly formed character array with a length equal to the given string and with the characters in the given string initialized as
Edureka Community
edureka.co › home › community › categories › java › how to convert string to char array in java
How to convert string to char array in Java | Edureka Community
October 27, 2023 - In Java programming, what is the recommended method for converting a String object into an array ... in which this conversion might be necessary ?
GeeksforGeeks
geeksforgeeks.org › java › java-string-tochararray-example
Java String toCharArray() Method With Example - GeeksforGeeks
July 11, 2025 - In Java, the toCharArray() method of the String class converts the given string into a character array. The returned array length is equal to the length of the string.
Top answer 1 of 8
8
String[] sArray = {"i", "love", "you"};
String s = "";
for (String n:sArray)
s+= n;
char[] c = s.toCharArray();
2 of 8
2
You can do that like this
char[] allchar = new char[total]; // Your code till here is proper
// Copying the contents of the 2d array to a new 1d array
int counter = 0; // Counter as the index of your allChar array
for (int i = 0; i < a1.length; i++) {
for (int j = 0; j < a1[i].length; j++) { // nested for loop - typical 2d array format
allchar[counter++] = a1[i][j]; // copying it to the new array
}
}
Scaler
scaler.com › home › topics › convert java string to character array
Convert Java String to Character Array - Scaler Topics
May 4, 2023 - Then, we are creating a char array of string length using the length() method, in which we will store all the characters of the String. Then we are copying character by character, which we are fetching by the charAt() method, into an array using for loop. Then we are printing the elements of ...
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-a-string-to-a-character-in-java
How to Convert a String to a Character in Java? - GeeksforGeeks
July 23, 2025 - There are 3 other methods using which we can convert a String to a char in Java. We can use the charAt() method in a loop to extract all characters from a string and then we can store them in a character array.
Mkyong
mkyong.com › home › java › java – how to convert string to char array
Java – How to convert String to Char Array | mkyong.com
July 27, 2016 - package com.mkyong.utils; public class StringToCharArray { public static void main(String[] args) { String password = "password123"; char[] passwordInCharArray = password.toCharArray(); for (char temp : passwordInCharArray) { System.out.println(temp); } } } ... package com.mkyong.utils; package com.mkyong.pageview; public class Test { public static void main(String[] args) { String password = "password123"; password.chars() //IntStream .mapToObj(x -> (char) x)//Stream<Character> .forEach(System.out::println); } }
Baeldung
baeldung.com › home › java › java string › convert string to char in java
Convert String to char in Java | Baeldung
January 8, 2024 - We’ll convert the source String to a char array that holds each character in the string. In this way, we can pick any elements according to the requirement. ... So next, let’s see them in action. Java’s String class provides the charAt() to get the n-th character (0-based) from the input string as char.
Programiz
programiz.com › java-programming › library › string › tochararray
Java String toCharArray() | Programiz
March 12, 2024 - The Java String toCharArray() method converts the string to a char array and returns it.