Java Char Array to Char hasCharAt(char toLookFor, int position, char[] toSearch)

Here you can find the source of hasCharAt(char toLookFor, int position, char[] toSearch)

Description

Returns true iff the given array contains the given char at the given position

License

Open Source License

Declaration

public static final boolean hasCharAt(char toLookFor, int position, char[] toSearch) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2016 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:/*from  w w  w  .  j ava2  s .co  m*/
 *     IBM Corporation - initial API and implementation
 *     Andrew Ferguson (Symbian)
 *     Markus Schorn (Wind River Systems)
 *     Sergey Prigogin (Google)
 *******************************************************************************/

public class Main {
    /**
     * Returns true iff the given array contains the given char at the given position
     */
    public static final boolean hasCharAt(char toLookFor, int position, char[] toSearch) {
        if (toSearch.length <= position) {
            return false;
        }

        return toSearch[position] == toLookFor;
    }
}

Related

  1. charArrayToLowerCase(char[] arr)
  2. charAt(char[] s, int pos)
  3. charAt(CharSequence chars, int i)
  4. charAt(CharSequence chars, int index, boolean ignoreCase)