Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

convert String to char  RSS feed

 
trupti nigam
Ranch Hand
Posts: 640
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

How to convert a string to char type?

Thanks,
Trupti
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the third character in the string myString,

 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively:

char[] chars = string.toCharArray();

See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
 
Chao Yuchen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String s = new String("...");
char[] c = s.toCharArray();
// I think it's good to find methods on Docs.
// I like find solutions in this way.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!