string.startsWith()

Test if a String starts with a provided prefix.

Signature

startsWith(prefix: String) => Boolean

Description

Tests if the calling String starts with a provided prefix.

Parameters

Parameter Type Required Description

prefix

String

true

Prefix to compare to the end of the calling String.

Return value

Type Description

Boolean

If true, the calling String ends with the prefix. Otherwise, false.

Examples

  1. Test whether a String starts with HTTP:

    "HTTP/1.1 200 OK".startsWith("HTTP")
    true
  2. Test whether a String starts with 200:

    "HTTP/1.1 200 OK".startsWith("200")
    false
\