Java - Write code to check if an Array Contains a String

Requirements

Write code to check if an Array Contains a String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String[] arrayString = new String[] { "1", "abc", "level", null,
                "book2s.com", "asdf 123" };
        String str = "book2s.com";
        System.out.println(ArrayContainString(arrayString, str));
    }// w w w .  j  ava 2  s . c o m

    public static boolean ArrayContainString(String[] arrayString,
            String str) {
        if (arrayString == null || arrayString.length == 0) {
            return false;
        }
        for (int i = 0; i < arrayString.length; i++) {
            if (arrayString[i].equals(str))
                return true;
        }
        return false;
    }
}