JAVA - Convert a char[] into a Character[]? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JAVA - Convert a char[] into a Character[]?

Hello, what is the best way to convert a char[] or a String into a Character[] with the normal JDK (Version didn't belong)? I ask to use it e.g.

9th Jul 2022, 2:14 PM
Nono Apfel
3 Answers
+ 1
In case of an array, just iterate over it and conert its elements one by one
9th Jul 2022, 5:37 PM
Ervis Meta
Ervis Meta - avatar
+ 1
Use Character.valueOf() for this purpose.
9th Jul 2022, 3:39 PM
Ervis Meta
Ervis Meta - avatar
0
But I want to convert a full array to another array an not only a char to a Character. And I know that you can create an Character[] and loop through it with a for loop an copy the values. But is this the best version?
9th Jul 2022, 5:30 PM
Nono Apfel