Java tutorial
//package com.java2s; //License from project: Apache License import java.util.List; import java.util.Locale; public class Main { /** * Check if the list contains the member. For objects, it uses standard .equals() method. * For strings, it compares but ignores the case. * * @param list * @param member * @return */ public static boolean contains(List<? extends Object> list, Object member) { if (list.isEmpty() || member == null) return false; for (Object obj : list) { if (obj instanceof String && member instanceof String) { if (compareIgnoreCase((String) obj, (String) member)) return true; } else { if (member.equals(obj)) return true; } } return false; } public static boolean compareIgnoreCase(String str1, String str2) { return str1.toLowerCase(Locale.ENGLISH).equals(str2.toLowerCase(Locale.ENGLISH)); } }