Can someone tell me why this code throws an Exception?
int value = 0xabcdef01;
System.out.println(value); // prints -1412567295
String hex = Integer.toHexString(value);
System.out.println(hex); // prints abcdef01
// why does this line fail?
Integer.parseInt(hex, 16);
This code throws the following exception:
java.lang.NumberFormatException: For input string: "abcdef01"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
I'm running on Windows 7 with the following JDK
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)