char c = '5';
To Integer
- Character.getNumericValue(c)
- int i = c - '0';
To Double
- double d = (double) (c - '0');
Character c = '5';
- Convert to char using c.charValue();
Double / double
double d = 1.0;
Double D = 1.0;
To Integer
- Integer i = D.intValue();
- int i = (int)d;
int / Integer
To Char
Integer.toString(i).charAt(0)
Generate char according to it's index
(char)('A' + i)
(char)('a' + i)
'A' + i and 'a' + i in java are ascii integers, need (char) to convert back to char.
To String
Integer.toString(i);
String
String s1 = '500';
String s2 = "5.0".
To Integer
- Integer.parseInt(s1);
To Double
- Double.praseDouble(s2);
No comments:
Post a Comment