Examples of smaller Java programs that do various interesting things.

SortedIntList.java 491B

1234567891011121314151617181920212223
  1. public class SortedIntList extends IntListVer3{
  2. public SortedIntList(int initialCap){
  3. //call IntList constructor
  4. super(initialCap);
  5. }
  6. public SortedIntList(){
  7. super();
  8. }
  9. //override add
  10. public void add(int value){
  11. //search for location to insert value
  12. int pos = 0;
  13. while( pos < size() && value > get(pos) ){
  14. pos++;
  15. }
  16. super.insert(pos, value);
  17. }
  18. }