Here you can find the source of searchFirst(String[] target, String key)
public static int searchFirst(String[] target, String key)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.List; public class Main { public static int searchFirst(String[] target, String key) { if (isEmpty(target) || key == null) { return -1; }// ww w.j a v a 2s . c o m for (int i = 0; i < target.length; i++) { if (key.equals(target[i])) { return i; } } return -1; } public static boolean isEmpty(String[] arg) { if (arg == null) { return true; } return arg.length == 0; } public static boolean equals(String[] fullSet, String[] subSet) { if (isEmpty(fullSet) && isEmpty(subSet)) { return true; } if (length(fullSet) != length(subSet)) { return false; } List<String> fullList = Arrays.asList(fullSet); List<String> subList = Arrays.asList(subSet); return fullList.containsAll(subList) && subList.containsAll(fullList); } public static int length(String[] strs) { if (isEmpty(strs)) { return 0; } return strs.length; } }