Java - Write code to search char value in an array of char

Requirements

Write code to search char value in an array of char

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        int iChr = 42;
        char[] chr = new char[] { 'b', 'o', 'o', 'k', '2', 's', '.', 'c',
                'o', 'm', 'a', '1', };
        System.out.println(charMatch(iChr, chr));
    }/*from w ww .j a  v a  2 s  .  c om*/

    private static boolean charMatch(int iChr, char[] chr) {
        for (int i = 0; i < chr.length; i++) {
            if (iChr == chr[i]) {
                return true;
            }
        }
        return false;
    }
}