public class Test2D extends Object
Modifier and Type | Method and Description |
---|---|
static String |
concat(List<String> t)
Returns the string formed by concatenating all of the strings contained
in the list t.
|
static String |
last(List<String> t)
Returns the string at the end of the list t
|
static String |
secondLast(List<String> t)
Returns the second last string in the list t
|
static void |
sortByLength(List<String> t)
Sorts a list of strings by their length (shortest first).
|
public static String last(List<String> t)
t
- a listpublic static String secondLast(List<String> t)
IllegalArgumentException
- if the length of the list is less than 2t
- a listpublic static String concat(List<String> t)
["he", "ll", "o"]
then the resulting string is "hello".
If the list is empty, then the returned string is equal to the empty string.
t
- a list of strings to concatenatepublic static void sortByLength(List<String> t)
["abstract", "boolean", "code", "char", "for"]
then t is modified so that it becomes:
["for", "char", "code", "boolean", "abstract"]
t
- the list to sort