目录

boolean startsWith(String prefix, int toffset)

描述 (Description)

如果字符串以指定的前缀开始指定的索引或默认情况下以字符串开头,则此方法有两个变体并进行测试。

语法 (Syntax)

以下是此方法的语法 -

public boolean startsWith(String prefix, int toffset)

参数 (Parameters)

这是参数的细节 -

  • prefix - 要匹配的前缀。

  • toffset - 从哪里开始查看字符串。

返回值 (Return Value)

  • 如果参数表示的字符序列是该字符串表示的字符序列的前缀,则返回true; 否则是假的。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to iowiki.com");
      System.out.print("Return Value :" );
      System.out.println(Str.startsWith("Tutorials", 11) );
   }
}

这将产生以下结果 -

输出 (Output)

Return Value :true
↑回到顶部↑
WIKI教程 @2018