Wednesday, March 28, 2012

Casting and Conversions in Java



Integer to string
int i=1234;
String s = String.valueOf(i);

String to Integer
String s = "5678";
int i = Integer.parseInt(s);

Character to string
char ch = 'a';
String s = Character.toString(ch);

Character to integer
char ch = '7';
int i = Character.getNumericValue(ch);





No comments:

Post a Comment