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

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cast a String to a char" Watch "Cast a String to a char" New topic

Cast a String to a char

Toulouse Laurent

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

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);
I agree. Here's the link:
subject: Cast a String to a char