Question

Exercise 2: Handling ArrayLists
Write an “Exercise02” class that defines the followingstatic
methods:
• Themethod
“printOrderedList” (below) that receives anarray list of strings
and a boolean value, and prints to the screenthese strings ordered
according to length. The list will be orderedin ascending or
descending order depending on the (true or false)value of the
boolean parameter. If several strings have the samelength they
should be printed in the order they have in thearray list.
public static void printOrderedList(ArrayList<String>
list,boolean ascending)
• Themethod
“printParagraphs” (below) that receives andarray list of strings
and an integer, and prints strings to thescreen in one line (in the
same order they have in the list) aslong as the number of
characters on that line is not higher thanthe integer number given
as a parameter. Printing subsequentstrings in one line will
eventually make the length of the line belonger than the limit; the
last string making it longer shouldbecome the first string on the
next line. Any string whose lengthis longer than the limit is
printed on its own line. Allstrings areseparated by one blank
space. Any string with leading or trailingblank spaces should have
them trimmed before being printed. Thelast string on a line should
not have blank trailing spaces.
public static void printParagraphs(ArrayList<String> list,int
limit)