判断字符串是否以prefix 开头。
boolean startsWith - 语法
public boolean startsWith(String prefix)
这是参数的详细信息-
prefix - 要匹配的前缀。
boolean startsWith - 返回值
如果是以prefix开头,则返回true,否则为false。
boolean startsWith - 示例
import java.io.*; public class Test { public static void main(String args[]) { String Str=new String("Welcome to Learnfk.com"); System.out.print("返回值 :" ); System.out.println(Str.startsWith("Welcome") ); System.out.print("返回值 :" ); System.out.println(Str.startsWith("LearnFK") ); } }
这将产生以下输出-
返回值 :true 返回值 :false