Java - Write code to look for key in array if found return true

Requirements

Write code to look for key in array if found return true

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String[] array = new String[] { "1", "abc", "level", null,
                "book2s.com", "asdf 123" };
        String key = "book2s.com";
        System.out.println(inArray(array, key));
    }/*from   w  w w .java  2  s  .  co m*/

    /**
     * look for key in array if found return true
     * @param array
     * @param key
     * @return if key one of the elemnts of array return true otherwise false
     */
    public static boolean inArray(String[] array, String key) {
        for (String string : array) {
            if (key.compareTo(string) == 0)
                return true;
        }
        return false;
    }
}