Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsSingletonExample1 { public static void main(String[] args) { List
list = new ArrayList<>(); Collections.addAll(list, 1, 2, 4, 2, 7, 2, 4, 4); System.out.println(list); list.remove(7); System.out.println(list); list.removeAll(Collections.singleton(4)); System.out.println(list); } }
Output