Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert a String to char

 
Ramakrishna Gummadi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the String.charAt and String.toCharArray methods.
 
Gihan Pandigamage
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String str = "A";
char ch= str.charAt(0);
System.out.println(ch);
 
Ramakrishna Gummadi
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gihan pandigamage wrote:String str = "A";
char ch= str.charAt(0);
System.out.println(ch);


Thank you dude....
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gihan pandigamage wrote:String str = "A";
char ch= str.charAt(0);
System.out.println(ch);



Or faster...

char ch = 'A';

;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic