Java contentEquals() 方法

Java 教程 · 2019-02-08 20:14:22

contentEquals() 方法用于将此字符串与指定的 StringBuffer 比较。

语法

public boolean contentEquals(StringBuffer sb)

参数

  • sb -- 要与字符串比较的 StringBuffer。

返回值

如字符串与指定 StringBuffer 表示相同的字符序列,则返回 true;否则返回 false。

实例

public class Test {
    public static void main(String args[]) {
        String str1 = "String1";
        String str2 = "String2";
        StringBuffer str3 = new StringBuffer( "String1");

        boolean  result = str1.contentEquals( str3 );
        System.out.println(result);
          
        result = str2.contentEquals( str3 );
        System.out.println(result);
    }
}

以上程序执行结果为:

true
false

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

Algorithms in C++

Algorithms in C++

Robert Sedgewick / Addison-Wesley Professional / 1992-05-10 / USD 64.99

This version of Sedgewick's bestselling book provides a comprehensive collection of algorithms implemented in C++. The algorithms included cover a broad range of fundamental and more advanced methods:......一起来看看 《Algorithms in C++》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具