java startswith code example

Example 1: js startswith

var str = "Hello world, welcome to the universe.";
var n = str.startsWith("Hello");

Example 2: string startswith java

public class StringExample 
{
    public static void main(String[] args) 
    {
        String blogName = "howtodoinjava.com";
         
        System.out.println( blogName.startsWith("how") );               //true
         
        System.out.println( "howtodoinjava.com".startsWith("howto") );  //true
         
        System.out.println( "howtodoinjava.com".startsWith("hello") );  //false
    }
}

Example 3: java string contains at beginning

public class StringExample 
{
    public static void main(String[] args) 
    {
        String blogName = "howtodoinjava.com";
         
        blogName.startsWith(null);
    }
}