Here you can find the source of inArray(int[] array, int needle)
Parameter | Description |
---|---|
array | a parameter |
needle | a parameter |
public static final boolean inArray(int[] array, int needle)
//package com.java2s; /******************************************************************************* * Copyright (c) 2008 Dennis Schenk, Peter Siska. * 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:/*from w w w .j ava 2 s . co m*/ * Dennis Schenk - initial implementation * Peter Siska - initial implementation *******************************************************************************/ public class Main { /** * * @param array * @param needle * @return True if the given needle is in the array. */ public static final boolean inArray(int[] array, int needle) { boolean found = false; for (int i = 0; i < array.length; i++) { if (array[i] == needle) { found = true; break; } } return found; } }