Java String startsWith(String prefix, int toffset)方法具有什么功能呢?
String startsWith(String prefix, int toffset)方法的功能
startsWith(String prefix, int toffset)方法的功能:检测字符串指定位置上的开头字符串
语法
public boolean startsWith(String prefix, int toffset)
参数
prefix:待检测的前缀字符串toffset:检测字符串的起始位置
返回值
当字符串指定区间,为prefix开头时,则返回true,否则返回false例
public class testClass {
public static void main(String args[]) {
String Str = new String("Welcome to java265.com");
System.out.print("Value :");
System.out.println(Str.startsWith("java265"));
System.out.print("Value :");
System.out.println(Str.startsWith("java265", 11));
}
}
/*
以上代码运行后,将输出以下信息
Value :false
Value :true
*/ 版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


