Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

String startswith()


The java string startsWith() method checks if this string starts with given prefix. It returns true if this string starts with given prefix else returns false.


Signature

The syntax or signature of startWith() method is given below.

  1. public boolean startsWith(String prefix)
  2. public boolean startsWith(String prefix, int offset)

Parameter

prefix : Sequence of character


Returns

true or false


Java String startsWith() method example

  1. public class StartsWithExample{
  2. public static void main(String args[]){
  3. String s1=“java string split method by Kreationnext;
  4. System.out.println(s1.startsWith(“ja”));
  5. System.out.println(s1.startsWith(“java string”));
  6. }}

Output:

true
true

Comments

comments