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.
Discussions

Java- Converting a string of numbers separated by spaces into an array?
You have the right idea. String.split() will return an array of strings. Then, if you want to treat any individual string in that array as an integer you can use Integer.parseInt() . If you want to create an array of integers, just make the array that way. More on reddit.com
🌐 r/learnprogramming
7
4
February 2, 2016
How to turn string into array
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
12
1
May 4, 2021
[University Programming (java)] Converting an array to string?
thanks all!! got it working More on reddit.com
🌐 r/HomeworkHelp
3
2
April 1, 2014
reduce an array to string
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
6
1
October 17, 2021
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 ...
🌐
Scaler
scaler.com › home › topics › convert string to array in java
String to Array in Java - Scaler Topics
April 19, 2024 - Strings in Java are objects which represent a sequence of characters. Java Strings are immutable, which implies their value cannot be changed once they are created. We can use a simple for loop or toCharArray() method to convert string to char array.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-string-to-string-array
Java Program to Convert String to String Array - GeeksforGeeks
July 23, 2025 - They are as follows: ... Create an array with string type. Split the given string using string_name.split(). Store splitted array into string array. Print the above string array. ... // Java Program to Convert String to String Array // Using ...
🌐
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.
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › string-to-array-java
How to Convert String to Array in Java | DigitalOcean
August 4, 2022 - From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › string to array in java
Converting String to Array in Java: A Comprehensive Guide
August 27, 2025 - Build strong programming foundations with upGrad’s courses in Java and other programming languages for full-stack development. ... The split() method can be used to break a string into an array of substrings based on a specified delimiter.
🌐
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 - Convert String to String array in Java with split(), handle regex delimiters, empty strings and emoji, and build a single-element array.
🌐
Quora
quora.com › How-do-convert-string-to-string-array-in-Java
How do convert string to string array in Java? - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
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
🌐
Centron
centron.de › home › tutorials › how to convert string to array in java
How to Convert String to Array in Java – centron
February 7, 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.
🌐
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!
🌐
Hostman
hostman.com › tutorials › converting-arrays-and-strings-in-java
Java Array to String and String to Array Conversion Guide
In Java, strings are treated as objects, and the language furnishes a robust set of methods for the manipulation of textual information. This tutorial provides a comprehensive guide on how to convert arrays to strings and strings to arrays in Java.
🌐
Reddit
reddit.com › r/learnprogramming › java- converting a string of numbers separated by spaces into an array?
r/learnprogramming on Reddit: Java- Converting a string of numbers separated by spaces into an array?
February 2, 2016 -

For example, I have String input which will look something like "5 6 6" but I need it to be converted into an array. What is the easiest way to do this? I have messed around with .split and .parseInt but have not come to any solid conclusions. Thanks!

🌐
Reddit
reddit.com › r/javahelp › how to turn string into array
r/javahelp on Reddit: How to turn string into array
May 4, 2021 -

Hello. I need help on turning a string example

String str = "Processor Mouse Power Supply Phone";

into an array of something like

String[][] arr = new String[]

arr[] = new String []{"Processor" , " Mouse" , "Power Supply" , "Phone"}

Also notice the "power supply " has two separate words. Any help is appreciated. Thank you

🌐
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
In Java programming, what is the recommended method for converting a String object into an array ... in which this conversion might be necessary ?
🌐
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 - That is to say, at runtime, the array returned by the toArray() method doesn’t know its elements’ concrete types. They could be String, Integer, or even mixed by different types since the Object class is the supertype of all other types.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array-to-string
Java String Array to String | DigitalOcean
August 3, 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.