Java - Write code to check if a string is In String Array

Requirements

Write code to check if a string is In String Array

Demo

//package com.book2s;

import java.util.List;

public class Main {
    public static void main(String[] argv) {
        String search = "book2s.com";
        String[] target = new String[] { "1", "abc", "level", null,
                "book2s.com", "asdf 123" };
        System.out.println(isInStringArr(search, target));
    }/*from   w w w .  j a va  2  s .c om*/

    public static Boolean isInStringArr(String search, String[] target) {
        Boolean bool = false;
        for (String t : target) {
            if (t.equals(search)) {
                bool = true;
                break;
            }
        }
        return bool;
    }

    public static Boolean isInStringArr(String search, List<String> target) {
        Boolean bool = false;
        if (target != null) {
            for (String t : target) {
                if (search.equals(t)) {
                    bool = true;
                    break;
                }
            }
        }
        return bool;
    }
}

Related Exercise