int i = 42; String str = Integer.toString(i);
String str = "" + i
String str = Double.toString(i);
String str = Long.toString(l);
String str = Float.toString(f);
str = "25"; int i = Integer.valueOf(str).intValue();
int i = Integer.parseInt(str);
double d = Double.valueOf(str).doubleValue();
long l = Long.valueOf(str).longValue();
long l = Long.parseLong(str);
float f = Float.valueOf(str).floatValue();
int i = 42; String binstr = Integer.toBinaryString(i);
int i = 42; String hexstr = Integer.toString(i, 16);
String hexstr = Integer.toHexString(i);
int i = Integer.valueOf("B8DA3", 16).intValue();
int i = Integer.parseInt("B8DA3", 16);
int i = 64; String aChar = new Character((char)i).toString();
char c = 'A'; int i = (int) c; // i will have the value 65 decimal
String test = "ABCD";
for ( int i = 0; i < test.length(); ++i ) {
char c = test.charAt( i );
int i = (int) c;
System.out.println(i);
}
b = (i != 0);
i = (b)?1:0;
note :To catch illegal number conversion, try using the try/catch mechanism.
try{
i = Integer.parseInt(aString);
} catch(NumberFormatException e) { }