Here you can find the source of substringCompare(String string, int index, char... characters)
Parameter | Description |
---|---|
string | The string to test against |
index | The location within the string |
characters | The character sequence to look for. |
private static boolean substringCompare(String string, int index, char... characters)
//package com.java2s; public class Main { /**/*from w ww . j av a 2s. c om*/ * Check if the given character sequence is located in the given * string at the specified index. If it is then return true, otherwise false. * * @param string The string to test against * @param index The location within the string * @param characters The character sequence to look for. * @return true if the character sequence was found, otherwise false. */ private static boolean substringCompare(String string, int index, char... characters) { // Is the string long enough? if (string.length() <= index + characters.length) return false; // Do all the characters match? for (char character : characters) { if (string.charAt(index) != character) return false; index++; } return false; } }