How I can convert a string into a character array without using toCharArray???
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
How I can convert a string into a character array without using toCharArray???
What have you tried so far? Show your effort and any errors/problems you are having.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
I have done it with toCharArray(). Now I want to know is there any way to do it without using toCharArray() ???? Is there any please let me know.
Think of the task logically. A string is an array of characters - so the string
"Hello" has 4 characters (starting at zero) and ends with a NULL terminating character.
H[0] E[1] ...etc
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
I am converting a String into a Char Array in this way. Now I want to do the same thing without using toCharArray(). so I want to know the alternative way.
Ada Lovelace (July 17th, 2014)
Ah, was not aware - thanks for the info Cornix appreciate itIn java strings are not terminated by a termination character. Thats in C++, C, etc.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
@Cornix @Ada LovelaceStill I cant find another way to do the same thing. Can anyone give me any link. It will be better for me if you give me any link and a hint both. As I am a beginner in java I cant do it
Please don't post multiple threads on the same topic. Your other thread was deleted.
As for your question, we will not write the code or do Internet searching for you. Review the String API for methods that you could use to do what you've described. Try writing the code, and if you run into problems or need help, post the code and ask specific questions about the help you need.
As you are a beginner, these are basic skills you need to learn and practice.
Have you tried to break the string into it's individual characters? As I said previously, a
string is an array of characters. Think about different ways to do this example: repetition.
When you have each character of the string, you can then work an algorithm to store the
character into it's own array.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)