This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes toCharArray() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toCharArray()" Watch "toCharArray()" New topic
Author

toCharArray()

Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
Hello
I copied small program and compiled. But I don't understand the purpose of toCharArray() function in Java. Can someone help me?
Thanks
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
it just creates an array of characters from a supplied string. They just give you the api you have to make a decision where to use it or not. I used it once where i want it to read the string backwards so i made char array using this method and then just looped from last element to first and constructed a new string in reverse order.


Val SCJP <BR>going for SCJD
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
public char[] toCharArray()
This function converts the string to a new character array. It returns a newly allocated character array whose length is the length of the string and whose contents are initialized to contain the character sequence represented by this string.


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
 
Consider Paul's rocket mass heater.
 
subject: toCharArray()