Write code to look for key in array if found return true
//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)); }/* w ww . j av a2 s .c o 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; } }