包装类中字符串类型转换成基本数据类型时,参数不应该得是相应类型的字符串表示形式吗?为什么这里写123456也没有报错,而是运行时显示false呢?
java包装类类型转换
java包装类类型转换
解决方案 »
- 杨辉三角问题求助
- JAVA 串口接收数据时如何能得到接收字符串的个数
- 输出一个电影视频 用java写
- 急!请问为什么使用定时器时,java.util.TimerTask中有获得数据库连接的任务不执行且无异常?
- 在linux下 怎么下 jdk,java运行环境呢,怎么配的呢? 高分求助啊
- [求助]applet 怎么看不到
- 对两个XML文件内容进行比较,如何得到不同的地方?或者给点思路!
- Hello world的错误
- 谁有java in a nutshell的电子版?要第3版或者第4版的。非常感谢
- 开机密码
- 求高人,java如何从记事本里读取数据并赋值?
- 关于泛型Collection<E>一个弱智问题.
return ((name != null) && name.equalsIgnoreCase("true"));
}
/**
* Parses the string argument as a boolean. The <code>boolean</code>
* returned represents the value <code>true</code> if the string argument
* is not <code>null</code> and is equal, ignoring case, to the string
* {@code "true"}. <p>
* Example: {@code Boolean.parseBoolean("True")} returns <tt>true</tt>.<br>
* Example: {@code Boolean.parseBoolean("yes")} returns <tt>false</tt>.
*
* @param s the <code>String</code> containing the boolean
* representation to be parsed
* @return the boolean represented by the string argument
* @since 1.5
*/
public static boolean parseBoolean(String s) {
return toBoolean(s);
}
源代码中很明显的解释了String类型转boolean类型的一个方法,当String的值为“true”时返回ture,当为其他字符串时返回false