import java.util.ArrayList; import java.util.Scanner; public class SalComp> extends ArrayList { /** * Required for serialization */ private static final long serialVersionUID = -7039052157199984372L; /** * Add a String to the sorted array list * @param stringToAdd */ public boolean add(C toAdd) { int loc = findPlace(toAdd); insertAtLoc(toAdd, loc); return true; } /** * Find the place in the arraylist to put the string * @param toAdd the string to be added * @return the location in which to put the stirng */ private int findPlace(C toAdd) { int place=0; while (place=atLoc; ll--) { set(ll+1, get(ll)); } set(atLoc, toAdd); } public void add(String toAdd, int atLoc) { System.err.println("Not Supported"); } public static void main(String[] args) { SalComp sal = new SalComp<>(); Scanner scann = new Scanner(System.in); System.out.print("Give me a String: "); String lin = scann.nextLine(); while (!lin.equals("0")) { sal.add(lin); System.out.print("Give me a String: "); lin = scann.nextLine(); } System.out.println(sal); scann.close(); } }