aspose 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
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
 
 
subject: Cast a String to a char