[单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h",&quot

[单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h",&quot,第1张

[单项选择题] 假设有以下代码:String s="hello";String t="hello";char c[ ]={"h","

[单项选择题] 假设有以下代码: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符合题意。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5589167.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-14

发表评论

登录后才能评论

评论列表(0条)

    保存