public static <T> int numTimes(T elem, List<T> list){

        if(list.size()<1){
            return 0;
        }
        else{
            if(list.get(0).equals(elem)){
                return 1+ numTimes(elem, list.subList(1, list.size()));
            }
            else{
                return numTimes(elem, list.subList(1, list.size()));
            }
        }
    }