如何在java中检查字符串是否以子字符串开头?

Xpl*_*ive -2 java string substring

我想检查一个以http://或不是开头的字符串.如果没有循环我怎么能这样做?提前致谢.

Kee*_*san 9

使用public boolean startsWith(String prefix)字符串 API

例如: boolean isStartsWith = YOUR_STRING.startsWith("http://");

String tst = "http://web.com";
System.out.print(tst.startsWith("http://")); //prints true
Run Code Online (Sandbox Code Playgroud)