String str = "t";
char ch = str.charAt[0];
or
String str = "test";
char[] chars = str.toCharArray;
amongst many other ways....
but surely you could have found that out yourself....
u r not understand about my question.i m trying to convert a character to ASCII.for instance,
char simple='A';
int val=(char)simple;
now i m having a problem coz i have a string which is alphanumeric n i want to convert the alphabet to int using ASCII. my code is like this:
String cardID="4Dr6g8WPa684Cvf";
for (int j=0;j<cardID.length();j++)
{
String subCard="";
subCard=cardID.substring(j,j+1);
if (subCard.equals("D"))
{//char cSubCard=String.toChar(subCard);
char val1=(char)subCard;
System.out.println("val1->"+val1);
}
}
there is error stating that "char val1=(char)subCard" incompatible data type.so what should i do?
String cardID="4Dr6g8WPa684Cvf";
for(int i = 0;i < cardId.length();++i)
{
if(cardId.charAt(i) == 'D')
System.out.println((int)cardId.charAt(i));
}