#How would I cast char[] to Character[]?

17 messages · Page 1 of 1 (latest)

silver dust
#

I have a class that uses a generic, for which I've specified Character here. It has a method which takes a T[], for which I'm trying to pass in a String.toCharArray(). How would I do this?

robust jettyBOT
#

This post has been reserved for your question.

Hey @silver dust! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gaunt sequoia
#

you wouldn't cast. they aren't compatible

silver dust
#

is there another way I could pass my char[] in?

gaunt sequoia
#

you could transform between them but i guess you'd probably need to loop to cast each individual Character to char since there's no specialization of CharStream

#

but this seems a bit like https://xyproblem.info to me, could you give some more context? why do you need to go from a generic to a specific primitive?

silver dust
#

im trying to pass a string in with toCharArray

#

so I need to cast a char[] to Character[]

#

not Character[] to char[]

gaunt sequoia
#

ohhhh i misread that heavily

#

mb hold on

#

yeah that makes a lot more sense
you still have to loop to transform though

#

there is ArrayUtils but it's not standard

silver dust
#

ok, thanks

robust jettyBOT
# silver dust ok, thanks

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

#
Post Closed

This post has been closed by @silver dust.