Use the toCharArray() method on the string str to convert it into an array of characters. This method splits the string into individual characters and returns an array containing those characters. Store the resulting character array in the variable charArray .