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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 35241
    
    7
Check out the String.charAt and String.toCharArray methods.


Android appsImageJ pluginsJava web charts
Gihan Pandigamage
Ranch Hand

Joined: Aug 23, 2009
Posts: 57
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to convert a String to char
 
Similar Threads
String to char.
How do I convert a String to a char?
Convert "\n" to char '\n'
convert Hex to Char or Dec
const char * to string