![[单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h",",第1张 [单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h",",第1张](/aiimages/%5B%E5%8D%95%E9%A1%B9%E9%80%89%E6%8B%A9%E9%A2%98%5D+%E5%81%87%E8%AE%BE%E6%9C%89%E4%BB%A5%E4%B8%8B%E4%BB%A3%E7%A0%81%EF%BC%9AString+s%3D%26amp%3Bquot%3Bhello%26amp%3Bquot%3B%EF%BC%9BString+t%3D%26amp%3Bquot%3Bhello%26amp%3Bquot%3B%EF%BC%9Bchar+c%5B+%5D%3D%7B%26amp%3Bquot%3Bh%26amp%3Bquot%3B%2C%26amp%3Bquot.png)
[单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h","e","l","l","o"}; 下列选项中,返回false的语句是______。
A.equals(;
B.equals(;
C.s==t;
D.equals(new String("hello"));
正确答案:B
参考解析:[分析] == *** 作符所比较的是 *** 作符两端的 *** 作数是否是同一个对象,而String的equals( )方法所比较的是两个String对象的内容是否一样,其参数是一个String对象时才有可能返回true,其他对象都返回false。因此只有选项B符合题意。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)