BZ易风

导航

 
public static void main(String[] args) {
        List list = new ArrayList();
        list.add("java");
        list.add("b");
        list.add("c");
        list.add("d");
        
//        int index = index(list,"e");
//        boolean isset = isSet(list,"java");
        boolean isset = list.contains("b");
        System.out.println(isset);
    }
    public static int index(List list, Object other){
        for(int i = 0;i<list.size();i++){
            Object obj = list.get(i);
            if(obj.equals(other)){
                return i;
            }
        }
        return -1;
    }
    public static boolean isSet(List list, Object other){
        int index = index(list,other);
        if(index>=0){
            return true;
        }else{
            return false;
        }
    }

 

posted on 2019-04-24 21:09  BZ易风  阅读(180)  评论(0编辑  收藏  举报