• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toCharArray()

 
Mike Shn
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 439
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic