Here you can find the source of arrayContains(String[] array, String value)
Parameter | Description |
---|---|
array | The array to look into |
value | The value to look for |
public static boolean arrayContains(String[] array, String value)
//package com.java2s; /*/*from w w w . j a v a2s.c om*/ * Copyright 2013 The Portico Project * * This file is part of cpptask. * * cpptask is free software; you can redistribute and/or modify it under the * terms of the Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * Use of this software is strictly AT YOUR OWN RISK!!! * Obtain a copy of the License at http://opensource.org/licenses/CDDL-1.0 * See the License for the specific language governing permissions and * limitations under the License. * */ public class Main { /** * Returns true if the given array contains the given value. False otherwise. Each * element will be stripped of whitespace before being compared. * * @param array The array to look into * @param value The value to look for */ public static boolean arrayContains(String[] array, String value) { for (String potential : array) { if (potential.trim().equals(value)) return true; } // didn't find it return false; } }