Java NumberFormatException弹出101836849? [英] Java NumberFormatException pops up for 101836849?

查看:111
本文介绍了Java NumberFormatException弹出101836849?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么会发生整数字符串,我想转换为整数?

Why is this happening with an integer string that I want to convert to integer?

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


推荐答案

您的号码字符串101836849具有字符&#65279(ZERO WIDTH NO这个角色被 Integer.parseInt 拒绝。

Your number string "101836849" has the character &#65279 (ZERO WIDTH NO-BREAK SPACE) at index 0. This character is rejected by Integer.parseInt.

通过打印字符串chars:

Verify this by printing the string chars:

for (int i=0; i<s.length(); i++)
    System.out.println((int)s.charAt(i));

这篇关于Java NumberFormatException弹出101836849?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆