Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Java String to "Character" Array Conversion

Soham1087

Newbie
Joined
May 31, 2022
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
India
Activity points
69
I'm trying to convert a String to an array of Character class objects, but I'm having trouble. I know that the toCharArray() method can convert a String to an array of primitive datatype type "char," but it doesn't help me convert a String to an array of objects of Character type.
To convert char to Character, use Character.valueOf in this article about converting string to array from scaler topics. Is that right? How should I go about it?
The code suggested by them:
Code:
String str = "testString";
char[] charArray = str.toCharArray();
Character[] charObjectArray = ArrayUtils.toObject(charArray);
 

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,479
Helped
1,183
Reputation
2,385
Reaction score
1,181
Trophy points
1,403
Location
Brazil
Activity points
54,958
I know that the toCharArray() method can convert a String to an array of primitive datatype type "char," but it doesn't help me convert a String to an array of objects of Character type.

The above code seems doing what is supposed to do.
What exactly is expected and what is actually going 'wrong' ?
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top