aspose 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


Win a copy of Spring in Action this week in the Spring forum!
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: 42285
    
  64
Check out the String.charAt and String.toCharArray methods.


Ping & DNS - my free Android networking tools app
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';

;)
 
wood burning stoves
 
subject: How to convert a String to char