public static void main(String[] args) {
Integer f = null;
try {
f = Integer.valueOf("12.3");
String s = f.toString();
int i = Integer.parseInt(s);
System.out.println("i = " + i);
} catch (Exception e) {
System.out.println("trouble : " + f + e);
}
}
Run Code Online (Sandbox Code Playgroud) java ×1