Studyon Minte9.com
Java SE




Conversion




package testexample; public class Test { public static void main(String[] args) { // --- Integer to String --- // String s = Integer.toString(2); String ss = Integer.toString(3); System.out.println(s + ss); // Outputs: 23 // --- String to Integer --- // Integer i = Integer.valueOf("2"); Integer ii = Integer.parseInt("3"); System.out.println(i + ii); // Outputs: 5 // --- String to Double --- // String s2 = "13.4"; Double d = Double.parseDouble(s2); System.out.println(d + 0.1); // Outputs: 13.5 // --- Double to Integer --- // Double d2 = 13.4; Integer i2 = d2.intValue(); System.out.println(i2); // Outputs: 13 } }
 


http://stackoverflow.com/questions/9102318/cast-double-to-integer-in-java