File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to convert a String to char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to convert a String to char " Watch "How to convert a String to char " New topic
Author

How to convert a String to char

Ramakrishna Gummadi
Greenhorn

Joined: Jun 29, 2011
Posts: 16
Hello friends
I want to know that how to convert a string value and store into char value.
ex:-


now i want to store in char ch;

thanks in advance....
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
Check out the String.charAt and String.toCharArray methods.


Ping & DNS - updated with new look and Ping home screen widget
Gihan Pandigamage
Ranch Hand

Joined: Aug 23, 2009
Posts: 60
String str = "A";
char ch= str.charAt(0);
System.out.println(ch);
Ramakrishna Gummadi
Greenhorn

Joined: Jun 29, 2011
Posts: 16
gihan pandigamage wrote:String str = "A";
char ch= str.charAt(0);
System.out.println(ch);


Thank you dude....
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

gihan pandigamage wrote:String str = "A";
char ch= str.charAt(0);
System.out.println(ch);



Or faster...

char ch = 'A';

;)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert a String to char
 
Similar Threads
const char * to string
convert Hex to Char or Dec
How do I convert a String to a char?
String to char.
Convert "\n" to char '\n'