To start you off on your assignment, String.split splits strings on a regular expression and this expression may be an empty string:

String[] ary = "abc".split("");

Yields the array:

(java.lang.String[]) [, a, b, c]

Getting rid of the empty 1st entry is left as an exercise for the reader :-)

Note: In Java 8, the empty first element is no longer included.

Answer from rsp on Stack Overflow
🌐
W3Schools
w3schools.com › java › java_howto_string_to_array.asp
Java How To Convert a String to an Array
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... There are many ways to convert a string to an array.
People also ask

What is a string in Java?
A string in Java is a sequence of characters enclosed within double quotes. String in Java are immutable that means once they are created their value can’t change. Any modifications to a string results in a new string object being created. A string in Java is a sequence of characters enclosed within double quotes. String in Java are immutable that means once they are created their value can’t change. Any modifications to a string results in a new string object being created. In Java, strings are fundamental data types used extensively in software development. However, there are scenarios where
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › string to array in java
Converting String to Array in Java: A Comprehensive Guide
Can we convert a string into a list instead of an array?
Yes, a string can be converted into a list by iterating over its characters or using built-in methods that transform it into a list of substrings or characters.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › string to array in java
Converting String to Array in Java: A Comprehensive Guide
How to handle empty strings when converting to an array?
You can handle empty strings by checking if the string is empty before conversion, setting a default value, or filtering out empty elements after conversion.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › string to array in java
Converting String to Array in Java: A Comprehensive Guide
🌐
freeCodeCamp
freecodecamp.org › news › string-to-array-in-java-how-to-convert-a-string-to-an-array-in-java
String to Array in Java – How to Convert Strings to Arrays
July 6, 2023 - Simplicity: The toCharArray() method provides a straightforward way to convert a string to a character array with just a single method call. Readability: The resulting character array can be easily manipulated, processed, or iterated over using ...
🌐
Centron
centron.de › home › tutorials › how to convert string to array in java
How to Convert String to Array in Java – centron
January 1, 2025 - The String class’s split(String regex) method can be used to convert a String to an array in Java. If you are working with Java regular expressions, you can also use the Pattern class’s split(String regex) method.
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-a-string-to-character-array-in-java
Convert a String to Character Array in Java - GeeksforGeeks
The toCharArray() method is the simplest and most efficient way to convert a string to a character array. ... // Java Program to Convert a String to a Character Array // using toCharArray() import java.util.Arrays; public class StringToCharArray ...
Published: July 12, 2025
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › string to array in java
Converting String to Array in Java: A Comprehensive Guide
August 27, 2025 - An array in Java is a data structure that stores multiple values of the same type in a contiguous memory location. Converting a string to array in java allows for easier processing, which includes extracting individual characters, splitting words, or performing operations like searching and sorting.
🌐
How to do in Java
howtodoinjava.com › home › java array › convert string to string array in java with split()
Convert String to String Array in Java with split()
February 22, 2023 - The usual way to convert a String to a String array in Java is split(), which cuts the text at every match of a delimiter regex and returns the pieces as a String[]; when we need the whole text as one element, we write new String[] {text} instead.
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java string › convert string to string array
Convert String to String Array | Baeldung
January 8, 2024 - We often need to work with input strings in specific patterns. In this case, we can break the inputs into a String array using regular expressions or regex. Java’s String class provides the split() method to do this job.
🌐
Scaler
scaler.com › home › topics › convert string to array in java
Convert String to Array in Java
April 19, 2024 - We've used the &d& delimiter here. ... We can convert a string to a string array by simply passing the string in the curly brackets of String [] {}. The impact of this conversion is that a String array will be created containing a single element - the input string itself.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-string-to-string-array
Java Program to Convert String to String Array - GeeksforGeeks
July 23, 2025 - Convert the given string into set of string. Now create an empty string array. Convert the string set to Array of string using set.toArray() by passing an empty array of type string. Print the array of string.
🌐
Hostman
hostman.com › tutorials › converting-arrays-and-strings-in-java
Java Array to String and String to Array Conversion Guide
Converting strings to arrays is often required, and the split() method in Java comes in handy for this task.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-string-to-integer-array
Java Program to Convert String to Integer Array - GeeksforGeeks
Below is the most concise and ideal for processing space-separated numbers or similar patterns to convert string to integer array. ... import java.util.Arrays; public class StrToIntArr { public static void main(String[] args) { String s = "1 2 3 4 5"; // Using Streams to convert the string into an integer array int[] arr = Arrays.stream(s.split(" ")) .mapToInt(Integer::parseInt) .toArray(); System.out.println("" + s); System.out.println("" + Arrays.toString(arr)); } }
Published: July 23, 2025
🌐
Baeldung
baeldung.com › home › java › java string › convert an arraylist of string to a string array in java
Convert an ArrayList of String to a String Array in Java | Baeldung
March 7, 2025 - String[] result2 = INPUT_LIST.toArray(new String[0]); assertArrayEquals(EXPECTED_ARRAY, result2); Let’s suppose we work with Java 8 or later.
🌐
YouTube
youtube.com › watch
How To Convert String To An Array In Java | Java Full Course From Scratch - YouTube
#iballdesigningdeveloper This video is about How To Convert String To An Array In Java | Java Full Course From ScratchYou can find awesome programming lesson...
Published: July 17, 2025
🌐
Delft Stack
delftstack.com › "delft stack" › "howto" › "java howtos" › "how to perform string to string array conversion in java"
How to Perform String to String Array Conversion in Java | Delft Stack
March 13, 2025 - For more complex scenarios, regular expressions offer a powerful way to convert strings to string arrays. This method allows you to specify intricate patterns for splitting strings, making it ideal for strings that contain various delimiters or need specific conditions for splitting. Here’s how to use regular expressions for this purpose: import java.util.regex.Pattern; public class StringToArrayRegex { public static void main(String[] args) { String str = "Java,Python;JavaScript C++"; String[] strArray = Pattern.compile("[,; ]").split(str); for (String s : strArray) { System.out.println(s); } } }
🌐
DigitalOcean
digitalocean.com › community › tutorials › string-to-array-java
How to Convert String to Array in Java | DigitalOcean
August 4, 2022 - Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
WsCube Tech
wscubetech.com › resources › java › programs › string-to-array
Convert String To Array in Java (6 Programs)
September 16, 2026 - Learn how to convert a String to an Array in Java with examples. Explore methods like for loop, split(), toCharArray(), split(" "), and more. Read now!
🌐
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 - Java 8: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html · Java 9: https://docs.oracle.com/javase/9/docs/api/java/lang/String.html ... This Website is really amazing. ... Man I really love this site. So many clean snippets. Reply Helpful Report Spam or advertising Abusive or offensive Off topic ... String testString = “test string”; char[] charArray = new char[testString.length()]; for(int i=0; i< testString.length();i++){ charArray[i] = testString.charAt(i); }
🌐
Java Code Geeks
javacodegeeks.com › home › core java
How to Split a String into an Int Array in Java - Java Code Geeks
November 10, 2025 - Each substring is then trimmed to remove unnecessary whitespace and converted into an integer. Finally, all parsed integers are stored in an int[], making the result ready for numerical processing. When you run the program, you should see the following output: ... This confirms that the string was successfully split using the comma delimiter, each element was parsed into an integer, and all values were stored correctly in the array. Java Streams provide a more concise and expressive way to convert a string into an int array.