您的位置:首页 > 编程语言 > Java开发

java基础----String类命令

2018-01-13 16:40 246 查看
1、 regionMatches方法

regionMatches方法用于检测两个字符串在一个区域内是否相等

public boolean regionMatches(int toffset, String other, it ooffset, int len)
public boolean regionMatches(boolean ignoreCase, int toffset, String other, it ooffset, int len)
param:
ignoreCase : 如果为true, 则比较字符时忽略大小写
toffset: 此字符串中子区域的起始偏移量
other: 字符串参数
ooffset: 字符串参数中子区域的起始偏移量
len: 要比较的字符数
retun:
如果成功比配,则返回true,否则返回false
例子:
String str1 = "m.runoob.com";
String str2 = "runoob";
System.out.println(str1.regionMatches(2, str2, 0,5));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string java