public static void println(Object o) { System.out.println(o); } public void printArray(List list) { println(" " + Arrays.toString(list.toArray())); }
//Constructing simple (given) list String[] strings = {"one", "two", "three", "four"}; List<String> list = new ArrayList<String>(Arrays.asList(strings)); println("Count: "); printArray(list); //One-Liner for simple (given) list List<String> names = new ArrayList<String>(Arrays.asList("Kofi", "Asha", "Bruce", "Sally")); println("Names: "); printArray(names);