Here you can find the source of startsWith(CharSequence str, char prefix)
public static boolean startsWith(CharSequence str, char prefix)
//package com.java2s; /*!/*from w ww .j a va 2s . co m*/ * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ public class Main { public static boolean startsWith(CharSequence str, char prefix) { if (str == null) { return false; } if (str.length() < 1) { return false; } char firstCh = str.charAt(0); return (firstCh == prefix); } public static boolean startsWith(CharSequence str, CharSequence prefix) { if (str == null) { return false; } if (prefix == null || prefix.length() == 0) { return true; } int len = prefix.length(); if (str.length() < len) { return false; } for (int i = 0; i < len; i++) { char ch = str.charAt(i); char prefixCh = prefix.charAt(i); if (ch != prefixCh) { return false; } } return true; } public static CharSequence startsWith(CharSequence str, CharSequence... prefixes) { if (str == null) { return null; } if (prefixes == null || prefixes.length == 0) { return null; } for (CharSequence prefix : prefixes) { if (startsWith(str, prefix)) { return prefix; } } return null; } }