WEB DEVELOPER SITE
PHP7
 

Java String startsWith() Method



Tests if this string starts with the specified prefix.


Syntax

Here is the syntax of this method โˆ’

public boolean startsWith(String prefix)

Parameters

Here is the detail of parameters โˆ’

  • prefix โˆ’ the prefix to be matched.

Return Value

  • It returns true if the character sequence represented by the argument is a prefix of the character sequence represented by this string; false otherwise.

Example

import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str = new String("Welcome to Welookups.com");

      System.out.print("Return Value :" );
      System.out.println(Str.startsWith("Welcome") );

      System.out.print("Return Value :" );
      System.out.println(Str.startsWith("Welook") );
   }
}
        Run example ยป