Here you can find the source of arrayContainsIgnoreCase(String[] array, String str)
Parameter | Description |
---|---|
array | The String array to search with |
str | The String to search for |
public static boolean arrayContainsIgnoreCase(String[] array, String str)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*ww w.j a va2 s . c om*/ * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Returns true if and only if the String array contains the given string, case insensitive. * @param array The String array to search with * @param str The String to search for * @return true if the String array contains the given String, case insensitive; false otherwise. */ public static boolean arrayContainsIgnoreCase(String[] array, String str) { if (array.length == 0) { return false; } for (int i = 0; i < array.length; i++) { if (array[i].equalsIgnoreCase(str)) return true; } return false; } /** * Tests whether two string are equal with ignoring the case. The difference to * String.equalsIgnoreCase is that in case s1 or s2 is null then this method returns * false. * * @param s1 first string to compare * @param s2 second string to comapre * @return true in case they are equal with ignore case */ public static boolean equalsIgnoreCase(String s1, String s2) { if (s1 == null || s2 == null) { return false; } return s1.equalsIgnoreCase(s2); } }