This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android this week in the Android 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
 
It's not a secret anymore!