In this article, we’ll look at how to convert a string to an array of characters in Java. I’ll also briefly explain to you what strings, characters, and arrays are.
Characters are primitive datatypes. A character is a single character enclosed inside single quotation marks. It can be a letter, a digit, a punctuation mark, a space or something similar. For example:
char firstVowel = 'a';
Strings are objects (reference type). A string is made up of a string of characters. It’s anything inside double quotation marks. For example:
String vowels = "aeiou";
Arrays are fundamental data structures which can store fixed number of elements of the same data type in Java. For example, let’s declare an array of characters:
char[] vowelArray = {'a', 'e', 'i', 'o', 'u'};
Now, we have a basic understanding about what strings, characters, and arrays are.
#java