File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Cast a String to a char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cast a String to a char" Watch "Cast a String to a char" New topic
Author

Cast a String to a char

Toulouse Laurent
Greenhorn

Joined: Oct 14, 2001
Posts: 8
Anyone know how to cast a String to a char?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

well, you don't. A String is an Object and a char is a primitive. If the String only has one one char in it, use char aChar = aString.charAt(0);
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cast a String to a char
 
Similar Threads
about char declair
How to cast a String to java.sql.types.CHAR
SQL ResultSet
SQL ResultSet
Operators