如何在java中检查字符串是否以子字符串开头?
我想检查是否以http://开头的字符串。没有循环我怎么做?提前感谢。在API中使用带有(字符串前缀)的如何在java中检查字符串是否以子字符串开头?,java,string,substring,Java,String,Substring,我想检查是否以http://开头的字符串。没有循环我怎么做?提前感谢。在API中使用带有(字符串前缀)的公共布尔startsWith 例如:boolean isStartsWith=YOUR_STRING.startsWith(“http://”) 你基本上可以使用最简单的方法。。。i、 e字符串API提供的方法 public boolean startsWith(String prefix, int toffset) or public boolean sta
公共布尔startsWith
例如:boolean isStartsWith=YOUR_STRING.startsWith(“http://”)代码>
你基本上可以使用最简单的方法。。。i、 e字符串API提供的方法
public boolean startsWith(String prefix, int toffset)
or
public boolean startsWith(String prefix)
例如:
String str = new String("http://www.google.com");
str.startsWith("http://");
如果满足条件,则返回true,否则将返回false。如果(str.indexOf(“http://”)==0)
?您的第一站应该始终是文档。
String str = new String("http://www.google.com");
str.startsWith("http://");