my dog learned polymorphism
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toCharArray()" Watch "toCharArray()" New topic


Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
I copied small program and compiled. But I don't understand the purpose of toCharArray() function in Java. Can someone help me?
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
I agree. Here's the link:
subject: toCharArray()
jQuery in Action, 3rd edition