本人刚开始学,很多都还没理解能请人帮忙讲解下吗?谢谢啊
1. Suppose s1 and s2 are two strings. Which of the following statements or expressions is incorrect?a) boolean b = s1.equals(s2);
b) boolean b = (s1 == s2);
c) boolean b = (s1 >= s2);
d) int b = s1.compareTo(s2);
e) boolean b = ((s1.length() – s2.length()) > 0 );2. Consider the following java code?
String s1 = “one”;
String s2 = new String(“one”);
String s3 = s1;Which of the following statement is true?
a) boolean b = (s1==s2);
b) boolean b = (s2==s3);
c) boolean b = (s2.equals(s3));
d) boolean b = (s1 == NULL);
e) boolean b = (s3.equals(“”));
1. Suppose s1 and s2 are two strings. Which of the following statements or expressions is incorrect?a) boolean b = s1.equals(s2);
b) boolean b = (s1 == s2);
c) boolean b = (s1 >= s2);
d) int b = s1.compareTo(s2);
e) boolean b = ((s1.length() – s2.length()) > 0 );2. Consider the following java code?
String s1 = “one”;
String s2 = new String(“one”);
String s3 = s1;Which of the following statement is true?
a) boolean b = (s1==s2);
b) boolean b = (s2==s3);
c) boolean b = (s2.equals(s3));
d) boolean b = (s1 == NULL);
e) boolean b = (s3.equals(“”));
解决方案 »
- struts2 + hibernate 怎么获得前台form中的值
- 求MyEclipse下Servlet程序的详细建立步骤
- 关于Excel文件的读取问题.急!!!!!!!!!!
- 持久化对象
- jsp获取参数的问题
- Apache MyFaces Trinidad 2.0.0-beta-2
- JAVA高手进
- 关于手动编译servlet servlet-api.jar要加到JDK/jre/lib/ext下?
- hibernate获取原始的数据库链接
- 在线等:spring+hibernate update时的简单问题
- struts如何用select实现多条件查询
- 在J2EE中操作数据库有没有必要rollback?
false
false
true
分析:字符串是没有>=这种表达式比较的,所以pass掉,e的话取长度是没错的,但是这里的长度要拿出来之后才能操作,不能直接操作的! 或者是在前面加个(int)转换下!
2 第三个是正确的,其它的都是false。 这里说下==和equals的区别,==是地址,equals是值比较。