File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert from string("a") to char..

 
Eung maeng
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone explain to me how to convert from string("Y") to char?

THANKS
 
John Lockheart
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String y = "Y";
char y_char = y.charAt(0);

And if the string is bigger than 1 letter you can do the same thing with a loop or break up the string and send it into a character array with the following:

String y = "hello";
char[] array = y.toCharArray();

array = {'h', 'e', 'l', 'l', 'o'}
 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I plan to use the following method to convert String to char:



This code doesn't throw an exception, but it doesn't print the null characters either.

Is this OK?

Kaydell
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic