Lists.java

All of the methods in here are static so they can call each other directly. Download the file Lists.java on the left. Save it and compile it. It will run right out of the box because I have stubbed in the methods with a pro forma return value of the corect type. Your job is to implement these methods. Read the specification for each method carefully!

I have created documentation for these functions; you can view it in the directory listdoc. The comments you see in this file are javadoc comments. I run javadoc on the program and the HTML markup is generated.


/**************************************************
*   Author: Your name please
*   Date:  26 Apr 2021
**************************************************/
import java.util.ArrayList;

public class Lists 
{
    public static void main(String[] args)
    {
        /*test drive your methods here.  Since everything is static,
         * you can call them directly.*/
    }
    /**
     * This returns a list with all of the even-indexed items
     * of a list in their index order.
     * @param list The list we are sampling from
     * @return the items in the list we passed in in index order.
     * The original list is NOT modified.
     */
    public static ArrayList<String> everyOther(ArrayList<String> list)
    {
        return new ArrayList<String>();
    }    
    /**
     * This reports the second-highest item in the list in 
     * alphabetical order, case-insensitive.  It does not modify
     * the original list.
     * @param list The list we are searching
     * @return The second-highest item in the list in alphabetical order,
     * case-insensitive.
     */
    public static String secondLargest(ArrayList<String> list)
    {
        return "";
    }    
    /**
     * This returns a new list with all items in the first half of
     * the alphabet in their original order.  This is case-insensitive.
     * It does not modify
     * the original list.
     * @param list The list we are filtering
     * @return a new list consisting of items int he first half of the 
     * alphabet from the list we passed in in their original order.
     * case-insensitive.
     */
    public static ArrayList<String> firstHalf(ArrayList<String> list)
    {
        return new ArrayList<String>();
    }    
    /**
     * This returns a new list that is truncated at the first instance
     * of the string <code>chop</code>, which will appear at the end of this
     * new list.
     * @param chop The string we are chopping at.
     * @param list The list being chopped.
     * @return a new list consisting of items int he first half of the 
     * alphabet from the list we passed in in their original order.
     * case-insensitive.
     */
    public static ArrayList<String> chopAt(ArrayList<String> list, String chop)
    {
        return new ArrayList<String>();
    }    
     /**  This takes a list of strings and upper-cases them all
     * in-place.  It modifies the original list.
     * @param list The list being upper-cased.
     */
    public static void capitalOffense(ArrayList<String> list)
    {
    }    
}