I want to check a string which starts with http://
or not. How can I do that without loop? Thanks in advance.
use public boolean startsWith(String prefix)
in String API
eg : boolean isStartsWith = YOUR_STRING.startsWith("http://");
String tst = "http://web.com";
System.out.print(tst.startsWith("http://")); //prints true
You can basically use the simplest method... i.e methods provided with the String API..
public boolean startsWith(String prefix, int toffset)
or
public boolean startsWith(String prefix)
For example :
String str = new String("http://www.google.com");
str.startsWith("http://");
It returns true if the condition is met else will return false.