Java - Write code to check if a char array contains a certain char

Requirements

Write code to check if a char array contains a certain char

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        char[] chars = new char[] { 'b', 'o', 'o', 'k', '2', 's', '.', 'c',
                'o', 'm', 'a', '1', };
        char ch = 'a';
        System.out.println(contains(chars, ch));
    }/*  ww  w. ja v a  2  s .co  m*/

    private static boolean contains(char[] chars, char ch) {
        for (char element : chars) {
            if (element == ch)
                return true;
        }

        return false;
    }
}