标签:blog io java 2014 log on amp c line
//摘自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()方法
标签:blog io java 2014 log on amp c line
原文地址:http://blog.csdn.net/pingzizzp/article/details/39035865