Write code to Given a string check to see if it is in a collection of strings (using equals())
//package com.book2s; public class Main { public static void main(String[] argv) { String searchString = "book2s.com"; String searchStringList = "book2s.com"; System.out.println(in(searchString, searchStringList)); }//from w ww. ja v a2s. c o m public static boolean in(final String searchString, final String... searchStringList) { if (searchString == null) { return false; } if (searchStringList.length == 0) { throw new IllegalArgumentException( "argument SearchStringList must have length > 0"); } for (final String s : searchStringList) { if (s.equals(searchString)) { return true; } } return false; } }