Programming Language JAVA
Implement a utility class named IterUI that has one
static method. This method, named print, takes as input any
object that implements the Iterable<E> interface
and returns a string containing the object's elements, each one
separated by a comma and a space.
public class IterUI{
#add your static print
method
}
Test Output Example
List<Integer> nums = Arrays.asList(new Integer[] {5, 4, 3,
2, 1});
IterUI.print(nums); // returns "5, 4, 3, 2,
1"
String sentence = "Hello my world is java";
Iterable<String> it = Arrays.asList(sentence.split("
"));
IterUI.print(it); // returns "Hello , my, world, is,
java"
Programming Language JAVA Implement a utility class named IterUI that has one static method. This method, named print, t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am