原因?
解决方案 »
- 请问从事j2ee多年的高手?
- struts2、Spring3、hibernate,运行时Action中提示service空指针
- 关于java 证书的问题
- java代码中整合Jmeter
- spring 执行多个任务时,长时间会导致系统缓慢。
- 软件行业2010年仍将保持快速增长
- JSP调用OCX控件,视频显示--求简单代码及讲解!!在线等,谢谢各位!!
- !!!!!!!!!!100分求解(struts下拉列表初始化数据)!!!!!!!!!!
- 新手请教:如何引入Notes.jar
- 用uploadify3.2.1上传图片,在后台servlet如何取动态传过来的值,本人菜鸟。
- JDBC 访问数据库出错地问题?
- 请问这样的网站是用什么形式构成的?
把它专成Int就是
Int b=Integer.parseInt(a); //使用固定的包装类,没有什么原因,就这么用的.
public static int parseInt(String s) throws NumberFormatException {
return parseInt(s,10);
}
所调用的本类的带两个参数的parseInt方法:
public static int parseInt(String s, int radix)
throws NumberFormatException
{
if (s == null) {
throw new NumberFormatException("null");
} if (radix < Character.MIN_RADIX) {
throw new NumberFormatException("radix " + radix +
" less than Character.MIN_RADIX");
} if (radix > Character.MAX_RADIX) {
throw new NumberFormatException("radix " + radix +
" greater than Character.MAX_RADIX");
} int result = 0;
boolean negative = false;
int i = 0, max = s.length();
int limit;
int multmin;
int digit; if (max > 0) {
if (s.charAt(0) == '-') {
negative = true;
limit = Integer.MIN_VALUE;
i++;
} else {
limit = -Integer.MAX_VALUE;
}
multmin = limit / radix;
if (i < max) {
digit = Character.digit(s.charAt(i++),radix);
if (digit < 0) {
throw NumberFormatException.forInputString(s);
} else {
result = -digit;
}
}
while (i < max) {
// Accumulating negatively avoids surprises near MAX_VALUE
digit = Character.digit(s.charAt(i++),radix);
if (digit < 0) {
throw NumberFormatException.forInputString(s);
}
if (result < multmin) {
throw NumberFormatException.forInputString(s);
}
result *= radix;
if (result < limit + digit) {
throw NumberFormatException.forInputString(s);
}
result -= digit;
}
} else {
throw NumberFormatException.forInputString(s);
}
if (negative) {
if (i > 1) {
return result;
} else { /* Only got "-" */
throw NumberFormatException.forInputString(s);
}
} else {
return -result;
}
}