首页 > 编程语言 > 详细

java API------Boolean类valueOf()方法

时间:2014-09-04 00:16:27      阅读:305      评论:0      收藏:0      [点我收藏+]

//摘自ocjp
public void testIfA() {
	if (testIfB("True")) {
		System.out.println("True");	
	} else {
		System.out.println("Not true");
	}
 }
public Boolean testIfB(String str) {
	return Boolean.valueOf(str);
}

What is the result when method testIfA is invoked?
A. True
B. Not true
C. An exception is thrown at runtime.
D. Compilation fails because of an error at line 12.
E. Compilation fails because of an error at line 19.
Answer: A


分析:

查看API:

//摘自Jdk1.6.21 API--Boolean类。
    public static Boolean valueOf(String s) {
	return toBoolean(s) ? TRUE : FALSE;
    }

    private static boolean toBoolean(String name) { 
	return ((name != null) && name.equalsIgnoreCase("true"));
    }

不难看出,此处不区分大小写。


java API------Boolean类valueOf()方法

原文:http://blog.csdn.net/pingzizzp/article/details/39035865

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!