char c = 'A'; char[] charArray = Character.toChars(c); System.out.println(Arrays.toString(charArray));
String str = "Hello"; char c = str.charAt(1); System.out.println(Arrays.toString(Character.toChars(c)));This code extracts the second character ('e') from the string "Hello" and converts it to a char array. The output will be '[e]', which is the single character 'e' represented as an array. The toChars() method is a static method of the Character class, which means that it can be accessed directly without creating an object of the class. The package library for this method is java.lang.