String 转Int计算总结

  1. String转Int, 往往需要挨个遍历拿到Char, 用char跟’0′, ‘a’, ‘A’做减法
  2. 注意是否落在’0′ 到’9’范围内。
  3. 注意validate其他字符的可能性
  4. 注意最后转换是否超出边界 Integer.MAX_VALUE
  5. 注意输入条件是否为null或者length 为0
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s