How to check a string starts with a substring or not in java?

后端 未结 2 1684
陌清茗
陌清茗 2020-12-22 13:54

I want to check a string which starts with http:// or not. How can I do that without loop? Thanks in advance.

2条回答
  •  攒了一身酷
    2020-12-22 14:16

    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
    

提交回复
热议问题