[单项选择题] 给出下面的代码,则以下()选项返回true。String s="hello";String t="hello";Char c[]

[单项选择题] 给出下面的代码,则以下()选项返回true。String s="hello";String t="hello";Char c[],第1张

[单项选择题] 给出下面的代码,则以下( )选项返回true。 String s="hello"; String t="hello"; Char c[]

[单项选择题] 给出下面的代码,则以下( )选项返回true。 String s="hello"; String t="hello"; Char c[]={"h","e","l","l","o"};

A.equals ( ;

B.equals ( ;

C.s==t;

D.t==c;

正确答案:

A

参考解析:

== *** 作符比较的是 *** 作符两端的 *** 作数是否是同一个对象,而String的equals()方法比较的是两个String对象的内容是否一样,其参数是一个String对象时才有可能返回true,其他对象都返回假。

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

原文地址: https://www.outofmemory.cn/zaji/5591139.html

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

发表评论

登录后才能评论

评论列表(0条)

保存