Here you can find the source of startsWith(T[] arr, T[] prefix)
Parameter | Description |
---|---|
arr | array to check prefix in |
prefix | prefix array |
T | type of array elements |
public static <T> boolean startsWith(T[] arr, T[] prefix)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . j a v a 2 s. c o m * Tests if the array starts with another prefix array. * @param arr array to check prefix in * @param prefix prefix array * @param <T> type of array elements * @return {@code true} if array starts with prefix, {@code false} otherwise */ public static <T> boolean startsWith(T[] arr, T[] prefix) { if (arr.length < prefix.length) return false; for (int i = 0; i < prefix.length; i++) { if (!arr[i].equals(prefix[i])) return false; } return true; } }