Converting String to "Character" array in Java

arrays, character, java, string

Solution

Use this:

String str = "testString";
char[] charArray = str.toCharArray();
Character[] charObjectArray = ArrayUtils.toObject(charArray);

Problem

I want to convert a `String` to an array of objects of Character class but I am unable to perform the conversion. I know that I can convert a String to an array of primitive datatype type "char" with the `toCharArray()` method but it doesn't help in converting a String to an array of objects of Character type. How would I go about doing so?

Original source