Java ConcurrentLinkedQueue removeAll() 方法2024年10月21日 | 2 分钟阅读 ConcurrentLinkedQueue 类的 removeAll() 方法用于移除 ConcurrentLinkedQueue 中与指定集合的项目匹配的元素。 语法参数在此,参数 c 是包含要从 ConcurrentLinkedQueue 中移除的元素的集合。 指定者:ConcurrentLinkedQueue 类的 removeAll () 方法由以下指定: Collection<E> 接口中的 removeAll。 返回值如果集合已更改,则 removeAll () 方法返回 Boolean 值 'true',否则返回 false。 抛出如果指定的集合不支持 null 元素,或者它包含一个或多个 null 元素,则它会抛出 NullPointerException。 示例 1输出 Queue : [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z] List of vowels : [A, E, I, O, U] Queue without vowels : [B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z] 示例 2输出 Total no : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Even no : [2, 4, 6, 8, 10] Odd no : [1, 3, 5, 7, 9] 示例 3输出 Exception in thread "main" java.lang.NullPointerException at java.util.concurrent.ConcurrentLinkedQueue.checkNotNull(ConcurrentLinkedQueue.java:920) at java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:327) at java.util.concurrent.ConcurrentLinkedQueue.add(ConcurrentLinkedQueue.java:297) at com.javaTpoint.ConcurrentLinkedQueueRemoveAllExample3.main(ConcurrentLinkedQueueRemoveAllExample3.java:12) |
我们请求您订阅我们的新闻通讯以获取最新更新。