Java - Write code to check if a string value is contained in a string array

Requirements

Write code to check if a string value is contained in a string array

Demo

//package com.book2s;

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

    /**
     * 
     * @param s
     * @param ss
     * @return
     */
    public static int contain(String s, String[] ss) {
        for (int i = 0; i < ss.length; i++) {
            if (s.equals(ss[i])) {
                return i;
            }
        }
        return -1;
    }
}