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));
    }/*from   w  w  w .  ja va  2 s  .  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;
    }
}