Here you can find the source of startsWith(String str, char prefix)
Parameter | Description |
---|---|
str | string to check first char |
prefix | the prefix. |
public static boolean startsWith(String str, char prefix)
//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(); } }