String#equals和String#contentEquals方法之间的区别 [英] Difference between String#equals and String#contentEquals methods

查看:118
本文介绍了String#equals和String#contentEquals方法之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String#equals 方法和 字符串#contentEquals 方法?

推荐答案

String#equals() 不仅要比较String的内容,还要检查另一个对象是否也是一个实例一个字符串 String#contentEquals() 仅比较内容(字符序列)并检查另一个对象是否也是<$的实例C $ C>字符串。它可以是任何东西,只要它是 <的实现。 code> CharSequence ,涵盖了ao String StringBuilder StringBuffer CharBuffer 等。

The String#equals() not only compares the String's contents, but also checks if the other object is also an instance of a String. The String#contentEquals() only compares the contents (the character sequence) and does not check if the other object is also an instance of String. It can be anything as long as it is an implementation of CharSequence which covers a.o. String, StringBuilder, StringBuffer, CharBuffer, etc.

这篇关于String#equals和String#contentEquals方法之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆