CSci 2101 Problem set 4: Java array lists

Due Tuesday, February 14th at 11:59pm (by e-mail)

15 points

Problem 1 (7 points)

Write and test a method that takes an ArrayList of integers and prints (doesn't return) its two smallest elements. Test your method carefully and submit all your test data.

Problem 2 (8 points)

Write and test a method that takes a string and returns an array or an array list of all its substrings, in any order. For instance, if the parameter string is "dog", the returned array (or an array list) will be ["d", "do", "dog", "o", "og", "g"] or some other ordering of the same strings. If the string has repeated letters then some of the substrings will be repeated, that's ok.

Hint: use nested loops, one for index of the starting character of the substring, and within it one for the index of the ending character. Use two different loop variables (such as i and j) for the two loops.

How to submit

Submit your Java file(s) to me by e-mail. The subject must be Problem Set N, where N is the problem set number. If working in a group, CC your group partner.


CSci 2101 course web site.