Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将十六进制字符串转换为Int时的java.lang.NumberFormatException_Java - Fatal编程技术网

将十六进制字符串转换为Int时的java.lang.NumberFormatException

将十六进制字符串转换为Int时的java.lang.NumberFormatException,java,Java,我想将十六进制字符串转换为十进制,但以下代码中出现错误: String hexValue = "23e90b831b74"; int i = Integer.parseInt(hexValue, 16); 错误: Exception in thread "main" java.lang.NumberFormatException: For input string: "23e90b831b74" at java.lang.NumberFormatException.for

我想将十六进制字符串转换为十进制,但以下代码中出现错误:

String hexValue = "23e90b831b74";       
int i = Integer.parseInt(hexValue, 16);
错误:

Exception in thread "main" java.lang.NumberFormatException: For input string: "23e90b831b74"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:495)

23e90b831b74
太大,无法装入
int

你可以通过数数数字很容易看出这一点。十六进制数中的每两个数字需要一个字节,因此12个数字需要6个字节,而
int
只有4个字节

使用
Long.parseLong

String hexValue = "23e90b831b74";       
long l = Long.parseLong(hexValue, 16);