Java String Starts Wtih startsWith(String str, char prefix)

Here you can find the source of startsWith(String str, char prefix)

Description

Tests if this string starts with the specified prefix.

License

LGPL

Parameter

Parameter Description
str string to check first char
prefix the prefix.

Return

is first of given type

Declaration

public static boolean startsWith(String str, char prefix) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/*from   w ww.j ava  2s.c o  m*/
     * Tests if this string starts with the specified prefix.
     * @param str string to check first char
     * @param prefix the prefix.
     * @return is first of given type
     */
    public static boolean startsWith(String str, char prefix) {
        return str != null && str.length() > 0 && str.charAt(0) == prefix;
    }

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }
}

Related

  1. startsWith(String s, String start)
  2. startsWith(String s1, String s2)
  3. startsWith(String self, String pattern)
  4. startsWith(String source, String target, boolean caseSensitive)
  5. startsWith(String str, char c)
  6. startsWith(String str, char prefix)
  7. startsWith(String str, String mark, int paramInt)
  8. startsWith(String str, String prefix)
  9. startsWith(String str, String prefix)